[FFmpeg-devel] [PATCH 1/2] WIP: Move CGA/EGA/VGA font to lavu as public API.

Clément Bœsch ubitux at gmail.com
Sun Sep 16 16:13:38 CEST 2012


On Sun, Sep 16, 2012 at 04:13:11PM +0200, Clément Bœsch wrote:
> XXX:
>  - rename to xga_font.*/cga_font.*/font.*?
>  - avpriv?
> 
> TODO:
>  - APIChanges
>  - bump micro lavc
>  - bump minor lavu
> ---
>  libavcodec/Makefile    |  12 +-
>  libavcodec/ansi.c      |  18 +-
>  libavcodec/bintext.c   |  10 +-
>  libavcodec/cga_data.c  | 444 -------------------------------------------------
>  libavcodec/cga_data.h  |  48 ------
>  libavcodec/pictordec.c |  12 +-
>  libavcodec/tmv.c       |   9 +-
>  libavutil/Makefile     |   2 +
>  libavutil/cga_data.c   | 444 +++++++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/cga_data.h   |  48 ++++++
>  10 files changed, 524 insertions(+), 523 deletions(-)
>  delete mode 100644 libavcodec/cga_data.c
>  delete mode 100644 libavcodec/cga_data.h
>  create mode 100644 libavutil/cga_data.c
>  create mode 100644 libavutil/cga_data.h
> 

Oups, sorry, forgot the -M. Attached a more readable version.

[...]

-- 
Clément B.
-------------- next part --------------
From 5c6aa6404f638fa6a1c4a47c7eb2eceda48c33d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Thu, 13 Sep 2012 01:07:55 +0200
Subject: [PATCH 1/2] WIP: Move CGA/EGA/VGA font to lavu as public API.

XXX:
 - rename to xga_font.*/cga_font.*/font.*?
 - avpriv?

TODO:
 - APIChanges
 - bump micro lavc
 - bump minor lavu
---
 libavcodec/Makefile                  | 12 ++++++------
 libavcodec/ansi.c                    | 18 +++++++++---------
 libavcodec/bintext.c                 | 10 +++++-----
 libavcodec/pictordec.c               | 12 ++++++------
 libavcodec/tmv.c                     |  9 ++++-----
 libavutil/Makefile                   |  2 ++
 {libavcodec => libavutil}/cga_data.c | 10 +++++-----
 {libavcodec => libavutil}/cga_data.h | 16 ++++++++--------
 8 files changed, 45 insertions(+), 44 deletions(-)
 rename {libavcodec => libavutil}/cga_data.c (99%)
 rename {libavcodec => libavutil}/cga_data.h (79%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index dd881b6..625abd0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -101,7 +101,7 @@ OBJS-$(CONFIG_AMV_ENCODER)             += mjpegenc.o mjpeg.o           \
                                           ratecontrol.o mpeg12data.o   \
                                           mpegvideo.o
 OBJS-$(CONFIG_ANM_DECODER)             += anm.o
-OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o cga_data.o
+OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o
 OBJS-$(CONFIG_APE_DECODER)             += apedec.o
 OBJS-$(CONFIG_ASS_DECODER)             += assdec.o ass.o ass_split.o
 OBJS-$(CONFIG_ASS_ENCODER)             += assenc.o ass.o
@@ -126,7 +126,7 @@ OBJS-$(CONFIG_BFI_DECODER)             += bfi.o
 OBJS-$(CONFIG_BINK_DECODER)            += bink.o binkdsp.o
 OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER)   += binkaudio.o wma.o wma_common.o
 OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER)  += binkaudio.o wma.o wma_common.o
-OBJS-$(CONFIG_BINTEXT_DECODER)         += bintext.o cga_data.o
+OBJS-$(CONFIG_BINTEXT_DECODER)         += bintext.o
 OBJS-$(CONFIG_BMP_DECODER)             += bmp.o msrledec.o
 OBJS-$(CONFIG_BMP_ENCODER)             += bmpenc.o
 OBJS-$(CONFIG_BMV_VIDEO_DECODER)       += bmv.o
@@ -222,7 +222,7 @@ OBJS-$(CONFIG_HUFFYUV_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_HUFFYUV_ENCODER)         += huffyuv.o
 OBJS-$(CONFIG_IAC_DECODER)             += imc.o
 OBJS-$(CONFIG_IDCIN_DECODER)           += idcinvideo.o
-OBJS-$(CONFIG_IDF_DECODER)             += bintext.o cga_data.o
+OBJS-$(CONFIG_IDF_DECODER)             += bintext.o
 OBJS-$(CONFIG_IFF_BYTERUN1_DECODER)    += iff.o
 OBJS-$(CONFIG_IFF_ILBM_DECODER)        += iff.o
 OBJS-$(CONFIG_IMC_DECODER)             += imc.o
@@ -332,7 +332,7 @@ OBJS-$(CONFIG_PGM_ENCODER)             += pnmenc.o pnm.o
 OBJS-$(CONFIG_PGMYUV_DECODER)          += pnmdec.o pnm.o
 OBJS-$(CONFIG_PGMYUV_ENCODER)          += pnmenc.o pnm.o
 OBJS-$(CONFIG_PGSSUB_DECODER)          += pgssubdec.o
-OBJS-$(CONFIG_PICTOR_DECODER)          += pictordec.o cga_data.o
+OBJS-$(CONFIG_PICTOR_DECODER)          += pictordec.o
 OBJS-$(CONFIG_PNG_DECODER)             += png.o pngdec.o pngdsp.o
 OBJS-$(CONFIG_PNG_ENCODER)             += png.o pngenc.o
 OBJS-$(CONFIG_PPM_DECODER)             += pnmdec.o pnm.o
@@ -417,7 +417,7 @@ OBJS-$(CONFIG_THP_DECODER)             += mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
 OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o tiff_data.o
 OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o tiff_data.o
-OBJS-$(CONFIG_TMV_DECODER)             += tmv.o cga_data.o
+OBJS-$(CONFIG_TMV_DECODER)             += tmv.o
 OBJS-$(CONFIG_TRUEHD_DECODER)          += mlpdec.o mlpdsp.o
 OBJS-$(CONFIG_TRUEMOTION1_DECODER)     += truemotion1.o
 OBJS-$(CONFIG_TRUEMOTION2_DECODER)     += truemotion2.o
@@ -484,7 +484,7 @@ OBJS-$(CONFIG_WS_SND1_DECODER)         += ws-snd1.o
 OBJS-$(CONFIG_XAN_DPCM_DECODER)        += dpcm.o
 OBJS-$(CONFIG_XAN_WC3_DECODER)         += xan.o
 OBJS-$(CONFIG_XAN_WC4_DECODER)         += xxan.o
-OBJS-$(CONFIG_XBIN_DECODER)            += bintext.o cga_data.o
+OBJS-$(CONFIG_XBIN_DECODER)            += bintext.o
 OBJS-$(CONFIG_XBM_DECODER)             += xbmdec.o
 OBJS-$(CONFIG_XBM_ENCODER)             += xbmenc.o
 OBJS-$(CONFIG_XL_DECODER)              += xl.o
diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c
index 3572500..d01fa15 100644
--- a/libavcodec/ansi.c
+++ b/libavcodec/ansi.c
@@ -24,10 +24,10 @@
  * ASCII/ANSI art decoder
  */
 
+#include "libavutil/cga_data.h"
 #include "libavutil/common.h"
 #include "libavutil/lfg.h"
 #include "avcodec.h"
-#include "cga_data.h"
 
 #define ATTR_BOLD         0x01  /**< Bold/Bright-foreground (mode 1) */
 #define ATTR_FAINT        0x02  /**< Faint (mode 2) */
@@ -78,7 +78,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
     avctx->pix_fmt = PIX_FMT_PAL8;
 
     /* defaults */
-    s->font        = ff_vga16_font;
+    s->font        = av_vga16_font;
     s->font_height = 16;
     s->fg          = DEFAULT_FG_COLOR;
     s->bg          = DEFAULT_BG_COLOR;
@@ -93,7 +93,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
 static void set_palette(uint32_t *pal)
 {
     int r, g, b;
-    memcpy(pal, ff_cga_palette, 16 * 4);
+    memcpy(pal, av_cga_palette, 16 * 4);
     pal += 16;
 #define COLOR(x) ((x) * 40 + 55)
     for (r = 0; r < 6; r++)
@@ -160,7 +160,7 @@ static void draw_char(AVCodecContext *avctx, int c)
         FFSWAP(int, fg, bg);
     if ((s->attributes & ATTR_CONCEALED))
         fg = bg;
-    ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
+    av_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
                     s->frame.linesize[0], s->font, s->font_height, c, fg, bg);
     s->x += FONT_WIDTH;
     if (s->x >= avctx->width) {
@@ -203,19 +203,19 @@ static int execute_code(AVCodecContext * avctx, int c)
         height = avctx->height;
         switch(s->args[0]) {
         case 0: case 1: case 4: case 5: case 13: case 19: //320x200 (25 rows)
-            s->font = ff_cga_font;
+            s->font = av_cga_font;
             s->font_height = 8;
             width  = 40<<3;
             height = 25<<3;
             break;
         case 2: case 3: //640x400 (25 rows)
-            s->font = ff_vga16_font;
+            s->font = av_vga16_font;
             s->font_height = 16;
             width  = 80<<3;
             height = 25<<4;
             break;
         case 6: case 14: //640x200 (25 rows)
-            s->font = ff_cga_font;
+            s->font = av_cga_font;
             s->font_height = 8;
             width  = 80<<3;
             height = 25<<3;
@@ -223,13 +223,13 @@ static int execute_code(AVCodecContext * avctx, int c)
         case 7: //set line wrapping
             break;
         case 15: case 16: //640x350 (43 rows)
-            s->font = ff_cga_font;
+            s->font = av_cga_font;
             s->font_height = 8;
             width  = 80<<3;
             height = 43<<3;
             break;
         case 17: case 18: //640x480 (60 rows)
-            s->font = ff_cga_font;
+            s->font = av_cga_font;
             s->font_height = 8;
             width  = 80<<3;
             height = 60<<4;
diff --git a/libavcodec/bintext.c b/libavcodec/bintext.c
index 8c12c59..45a8bed 100644
--- a/libavcodec/bintext.c
+++ b/libavcodec/bintext.c
@@ -28,9 +28,9 @@
  * iCEDraw File decoder
  */
 
+#include "libavutil/cga_data.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
-#include "cga_data.h"
 #include "bintext.h"
 
 typedef struct XbinContext {
@@ -71,7 +71,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
         }
     } else {
         for (i = 0; i < 16; i++)
-            s->palette[i] = 0xFF000000 | ff_cga_palette[i];
+            s->palette[i] = 0xFF000000 | av_cga_palette[i];
     }
 
     if ((s->flags & BINTEXT_FONT)) {
@@ -82,10 +82,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
             av_log(avctx, AV_LOG_WARNING, "font height %i not supported\n", s->font_height);
             s->font_height = 8;
         case 8:
-            s->font = ff_cga_font;
+            s->font = av_cga_font;
             break;
         case 16:
-            s->font = ff_vga16_font;
+            s->font = av_vga16_font;
             break;
         }
     }
@@ -117,7 +117,7 @@ static void draw_char(AVCodecContext *avctx, int c, int a)
     XbinContext *s = avctx->priv_data;
     if (s->y > avctx->height - s->font_height)
         return;
-    ff_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
+    av_draw_pc_font(s->frame.data[0] + s->y * s->frame.linesize[0] + s->x,
                     s->frame.linesize[0], s->font, s->font_height, c,
                     a & 0x0F, a >> 4);
     s->x += FONT_WIDTH;
diff --git a/libavcodec/pictordec.c b/libavcodec/pictordec.c
index 5d1e6ee..cb896a7 100644
--- a/libavcodec/pictordec.c
+++ b/libavcodec/pictordec.c
@@ -24,10 +24,10 @@
  * Pictor/PC Paint decoder
  */
 
+#include "libavutil/cga_data.h"
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
 #include "bytestream.h"
-#include "cga_data.h"
 
 typedef struct PicContext {
     AVFrame frame;
@@ -168,18 +168,18 @@ static int decode_frame(AVCodecContext *avctx,
         int idx = bytestream2_get_byte(&s->g);
         npal = 4;
         for (i = 0; i < npal; i++)
-            palette[i] = ff_cga_palette[ cga_mode45_index[idx][i] ];
+            palette[i] = av_cga_palette[ cga_mode45_index[idx][i] ];
     } else if (etype == 2) {
         npal = FFMIN(esize, 16);
         for (i = 0; i < npal; i++) {
             int pal_idx = bytestream2_get_byte(&s->g);
-            palette[i]  = ff_cga_palette[FFMIN(pal_idx, 16)];
+            palette[i]  = av_cga_palette[FFMIN(pal_idx, 16)];
         }
     } else if (etype == 3) {
         npal = FFMIN(esize, 16);
         for (i = 0; i < npal; i++) {
             int pal_idx = bytestream2_get_byte(&s->g);
-            palette[i]  = ff_ega_palette[FFMIN(pal_idx, 63)];
+            palette[i]  = av_ega_palette[FFMIN(pal_idx, 63)];
         }
     } else if (etype == 4 || etype == 5) {
         npal = FFMIN(esize / 3, 256);
@@ -195,10 +195,10 @@ static int decode_frame(AVCodecContext *avctx,
         } else if (bpp == 2) {
             npal = 4;
             for (i = 0; i < npal; i++)
-                palette[i] = ff_cga_palette[ cga_mode45_index[0][i] ];
+                palette[i] = av_cga_palette[ cga_mode45_index[0][i] ];
         } else {
             npal = 16;
-            memcpy(palette, ff_cga_palette, npal * 4);
+            memcpy(palette, av_cga_palette, npal * 4);
         }
     }
     // fill remaining palette entries
diff --git a/libavcodec/tmv.c b/libavcodec/tmv.c
index e2397ce..a8143b1 100644
--- a/libavcodec/tmv.c
+++ b/libavcodec/tmv.c
@@ -29,10 +29,9 @@
 #include <string.h>
 
 #include "avcodec.h"
+#include "libavutil/cga_data.h"
 #include "libavutil/internal.h"
 
-#include "cga_data.h"
-
 typedef struct TMVContext {
     AVFrame pic;
 } TMVContext;
@@ -67,15 +66,15 @@ static int tmv_decode_frame(AVCodecContext *avctx, void *data,
     dst                = tmv->pic.data[0];
 
     tmv->pic.palette_has_changed = 1;
-    memcpy(tmv->pic.data[1], ff_cga_palette, 16 * 4);
+    memcpy(tmv->pic.data[1], av_cga_palette, 16 * 4);
 
     for (y = 0; y < char_rows; y++) {
         for (x = 0; x < char_cols; x++) {
             c  = *src++;
             bg = *src  >> 4;
             fg = *src++ & 0xF;
-            ff_draw_pc_font(dst + x * 8, tmv->pic.linesize[0],
-                            ff_cga_font, 8, c, fg, bg);
+            av_draw_pc_font(dst + x * 8, tmv->pic.linesize[0],
+                            av_cga_font, 8, c, fg, bg);
         }
         dst += tmv->pic.linesize[0] * 8;
     }
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 75039b1..e9c73d6 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -14,6 +14,7 @@ HEADERS = adler32.h                                                     \
           blowfish.h                                                    \
           bprint.h                                                      \
           bswap.h                                                       \
+          cga_data.h                                                    \
           common.h                                                      \
           cpu.h                                                         \
           crc.h                                                         \
@@ -61,6 +62,7 @@ OBJS = adler32.o                                                        \
        base64.o                                                         \
        blowfish.o                                                       \
        bprint.o                                                         \
+       cga_data.o                                                       \
        cpu.o                                                            \
        crc.o                                                            \
        des.o                                                            \
diff --git a/libavcodec/cga_data.c b/libavutil/cga_data.c
similarity index 99%
rename from libavcodec/cga_data.c
rename to libavutil/cga_data.c
index 46097bb..6a0739d 100644
--- a/libavcodec/cga_data.c
+++ b/libavutil/cga_data.c
@@ -26,7 +26,7 @@
 #include <stdint.h>
 #include "cga_data.h"
 
-const uint8_t ff_cga_font[2048] = {
+const uint8_t av_cga_font[2048] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e,
  0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00,
  0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c,
@@ -157,7 +157,7 @@ const uint8_t ff_cga_font[2048] = {
  0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
-const uint8_t ff_vga16_font[4096] = {
+const uint8_t av_vga16_font[4096] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x7e, 0xff, 0xdb, 0xff, 0xff, 0xc3, 0xe7, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00,
@@ -416,12 +416,12 @@ const uint8_t ff_vga16_font[4096] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-const uint32_t ff_cga_palette[16] = {
+const uint32_t av_cga_palette[16] = {
     0xFF000000, 0xFF0000AA, 0xFF00AA00, 0xFF00AAAA, 0xFFAA0000, 0xFFAA00AA, 0xFFAA5500, 0xFFAAAAAA,
     0xFF555555, 0xFF5555FF, 0xFF55FF55, 0xFF55FFFF, 0xFFFF5555, 0xFFFF55FF, 0xFFFFFF55, 0xFFFFFFFF,
 };
 
-const uint32_t ff_ega_palette[64] = {
+const uint32_t av_ega_palette[64] = {
     0xFF000000, 0xFF0000AA, 0xFF00AA00, 0xFF00AAAA, 0xFFAA0000, 0xFFAA00AA, 0xFFAAAA00, 0xFFAAAAAA,
     0xFF000055, 0xFF0000FF, 0xFF00AA55, 0xFF00AAFF, 0xFFAA0055, 0xFFAA00FF, 0xFFAAAA55, 0xFFAAAAFF,
     0xFF005500, 0xFF0055AA, 0xFF00FF00, 0xFF00FFAA, 0xFFAA5500, 0xFFAA55AA, 0xFFAAFF00, 0xFFAAFFAA,
@@ -432,7 +432,7 @@ const uint32_t ff_ega_palette[64] = {
     0xFF555555, 0xFF5555FF, 0xFF55FF55, 0xFF55FFFF, 0xFFFF5555, 0xFFFF55FF, 0xFFFFFF55, 0xFFFFFFFF
 };
 
-void ff_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg)
+void av_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg)
 {
     int char_y, mask;
     for (char_y = 0; char_y < font_height; char_y++) {
diff --git a/libavcodec/cga_data.h b/libavutil/cga_data.h
similarity index 79%
rename from libavcodec/cga_data.h
rename to libavutil/cga_data.h
index 998dcca..deef43e 100644
--- a/libavcodec/cga_data.h
+++ b/libavutil/cga_data.h
@@ -23,15 +23,15 @@
  * CGA/EGA/VGA ROM data
  */
 
-#ifndef AVCODEC_CGA_DATA_H
-#define AVCODEC_CGA_DATA_H
+#ifndef AVUTIL_CGA_DATA_H
+#define AVUTIL_CGA_DATA_H
 
 #include <stdint.h>
 
-extern const uint8_t ff_cga_font[2048];
-extern const uint8_t ff_vga16_font[4096];
-extern const uint32_t ff_cga_palette[16];
-extern const uint32_t ff_ega_palette[64];
+extern const uint8_t av_cga_font[2048];
+extern const uint8_t av_vga16_font[4096];
+extern const uint32_t av_cga_palette[16];
+extern const uint32_t av_ega_palette[64];
 
 /**
  * Draw CGA/EGA/VGA font to 8-bit pixel buffer
@@ -43,6 +43,6 @@ extern const uint32_t ff_ega_palette[64];
  * @param fg,bg Foreground and background palette index
  * @param ch Character to draw
  */
-void ff_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg);
+void av_draw_pc_font(uint8_t *dst, int linesize, const uint8_t *font, int font_height, int ch, int fg, int bg);
 
-#endif /* AVCODEC_CGA_DATA_H */
+#endif /* AVUTIL_CGA_DATA_H */
-- 
1.7.12

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120916/b1aa7f18/attachment.asc>


More information about the ffmpeg-devel mailing list