FFmpeg  4.0
Data Structures | Macros | Functions | Variables
libzvbi-teletextdec.c File Reference
#include "avcodec.h"
#include "libavcodec/ass.h"
#include "libavcodec/dvbtxt.h"
#include "libavutil/opt.h"
#include "libavutil/bprint.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include <libzvbi.h>

Go to the source code of this file.

Data Structures

struct  TeletextPage
 
struct  TeletextContext
 

Macros

#define TEXT_MAXSZ   (25 * (56 + 1) * 4 + 2)
 
#define VBI_NB_COLORS   40
 
#define VBI_TRANSPARENT_BLACK   8
 
#define RGBA(r, g, b, a)   (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
 
#define VBI_R(rgba)   (((rgba) >> 0) & 0xFF)
 
#define VBI_G(rgba)   (((rgba) >> 8) & 0xFF)
 
#define VBI_B(rgba)   (((rgba) >> 16) & 0xFF)
 
#define VBI_A(rgba)   (((rgba) >> 24) & 0xFF)
 
#define MAX_BUFFERED_PAGES   25
 
#define BITMAP_CHAR_WIDTH   12
 
#define BITMAP_CHAR_HEIGHT   10
 
#define MAX_SLICES   64
 
#define OFFSET(x)   offsetof(TeletextContext, x)
 
#define SD   AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Functions

static int chop_spaces_utf8 (const unsigned char *t, int len)
 
static void subtitle_rect_free (AVSubtitleRect **sub_rect)
 
static char * create_ass_text (TeletextContext *ctx, const char *text)
 
static int gen_sub_text (TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
 
static void fix_transparency (TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top, int resx, int resy)
 
static int gen_sub_bitmap (TeletextContext *ctx, AVSubtitleRect *sub_rect, vbi_page *page, int chop_top)
 
static void handler (vbi_event *ev, void *user_data)
 
static int slice_to_vbi_lines (TeletextContext *ctx, uint8_t *buf, int size)
 
static int teletext_decode_frame (AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
 
static int teletext_init_decoder (AVCodecContext *avctx)
 
static int teletext_close_decoder (AVCodecContext *avctx)
 
static void teletext_flush (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass teletext_class
 
AVCodec ff_libzvbi_teletext_decoder
 

Macro Definition Documentation

◆ TEXT_MAXSZ

#define TEXT_MAXSZ   (25 * (56 + 1) * 4 + 2)

Definition at line 32 of file libzvbi-teletextdec.c.

Referenced by gen_sub_text().

◆ VBI_NB_COLORS

#define VBI_NB_COLORS   40

Definition at line 33 of file libzvbi-teletextdec.c.

Referenced by fix_transparency(), and gen_sub_bitmap().

◆ VBI_TRANSPARENT_BLACK

#define VBI_TRANSPARENT_BLACK   8

Definition at line 34 of file libzvbi-teletextdec.c.

Referenced by fix_transparency(), and gen_sub_bitmap().

◆ RGBA

#define RGBA (   r,
  g,
  b,
  a 
)    (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))

Definition at line 35 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ VBI_R

#define VBI_R (   rgba)    (((rgba) >> 0) & 0xFF)

Definition at line 36 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ VBI_G

#define VBI_G (   rgba)    (((rgba) >> 8) & 0xFF)

Definition at line 37 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ VBI_B

#define VBI_B (   rgba)    (((rgba) >> 16) & 0xFF)

Definition at line 38 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ VBI_A

#define VBI_A (   rgba)    (((rgba) >> 24) & 0xFF)

Definition at line 39 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ MAX_BUFFERED_PAGES

#define MAX_BUFFERED_PAGES   25

Definition at line 40 of file libzvbi-teletextdec.c.

Referenced by handler().

◆ BITMAP_CHAR_WIDTH

#define BITMAP_CHAR_WIDTH   12

Definition at line 41 of file libzvbi-teletextdec.c.

Referenced by fix_transparency(), gen_sub_bitmap(), and teletext_init_decoder().

◆ BITMAP_CHAR_HEIGHT

#define BITMAP_CHAR_HEIGHT   10

Definition at line 42 of file libzvbi-teletextdec.c.

Referenced by fix_transparency(), gen_sub_bitmap(), and teletext_init_decoder().

◆ MAX_SLICES

#define MAX_SLICES   64

Definition at line 43 of file libzvbi-teletextdec.c.

Referenced by slice_to_vbi_lines().

◆ OFFSET

#define OFFSET (   x)    offsetof(TeletextContext, x)

Definition at line 540 of file libzvbi-teletextdec.c.

◆ SD

Definition at line 541 of file libzvbi-teletextdec.c.

Function Documentation

◆ chop_spaces_utf8()

static int chop_spaces_utf8 ( const unsigned char *  t,
int  len 
)
static

Definition at line 81 of file libzvbi-teletextdec.c.

Referenced by gen_sub_text().

◆ subtitle_rect_free()

static void subtitle_rect_free ( AVSubtitleRect **  sub_rect)
static

Definition at line 92 of file libzvbi-teletextdec.c.

Referenced by teletext_close_decoder(), and teletext_decode_frame().

◆ create_ass_text()

static char* create_ass_text ( TeletextContext ctx,
const char *  text 
)
static

Definition at line 100 of file libzvbi-teletextdec.c.

Referenced by gen_sub_text().

◆ gen_sub_text()

static int gen_sub_text ( TeletextContext ctx,
AVSubtitleRect sub_rect,
vbi_page *  page,
int  chop_top 
)
static

Definition at line 117 of file libzvbi-teletextdec.c.

Referenced by handler().

◆ fix_transparency()

static void fix_transparency ( TeletextContext ctx,
AVSubtitleRect sub_rect,
vbi_page *  page,
int  chop_top,
int  resx,
int  resy 
)
static

Definition at line 184 of file libzvbi-teletextdec.c.

Referenced by gen_sub_bitmap().

◆ gen_sub_bitmap()

static int gen_sub_bitmap ( TeletextContext ctx,
AVSubtitleRect sub_rect,
vbi_page *  page,
int  chop_top 
)
static

Definition at line 223 of file libzvbi-teletextdec.c.

Referenced by handler().

◆ handler()

static void handler ( vbi_event *  ev,
void user_data 
)
static

◆ slice_to_vbi_lines()

static int slice_to_vbi_lines ( TeletextContext ctx,
uint8_t buf,
int  size 
)
static

Definition at line 358 of file libzvbi-teletextdec.c.

Referenced by teletext_decode_frame().

◆ teletext_decode_frame()

static int teletext_decode_frame ( AVCodecContext avctx,
void data,
int data_size,
AVPacket pkt 
)
static

Definition at line 388 of file libzvbi-teletextdec.c.

◆ teletext_init_decoder()

static int teletext_init_decoder ( AVCodecContext avctx)
static

Definition at line 486 of file libzvbi-teletextdec.c.

◆ teletext_close_decoder()

static int teletext_close_decoder ( AVCodecContext avctx)
static

Definition at line 518 of file libzvbi-teletextdec.c.

Referenced by teletext_flush().

◆ teletext_flush()

static void teletext_flush ( AVCodecContext avctx)
static

Definition at line 535 of file libzvbi-teletextdec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"txt_page", "list of teletext page numbers to decode, * is all", OFFSET(pgno), AV_OPT_TYPE_STRING, {.str = "*"}, 0, 0, SD},
{"txt_chop_top", "discards the top teletext line", OFFSET(chop_top), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, SD},
{"txt_format", "format of the subtitles (bitmap or text)", OFFSET(format_id), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD, "txt_format"},
{"bitmap", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, SD, "txt_format"},
{"text", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, SD, "txt_format"},
{"txt_left", "x offset of generated bitmaps", OFFSET(x_offset), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 65535, SD},
{"txt_top", "y offset of generated bitmaps", OFFSET(y_offset), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 65535, SD},
{"txt_chop_spaces", "chops leading and trailing spaces from text", OFFSET(chop_spaces), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, SD},
{"txt_duration", "display duration of teletext pages in msecs", OFFSET(sub_duration), AV_OPT_TYPE_INT, {.i64 = 30000}, 0, 86400000, SD},
{"txt_transparent", "force transparent background of the teletext", OFFSET(transparent_bg), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, SD},
{"txt_opacity", "set opacity of the transparent background", OFFSET(opacity), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 255, SD},
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
#define SD

Definition at line 542 of file libzvbi-teletextdec.c.

◆ teletext_class

const AVClass teletext_class
static
Initial value:
= {
.class_name = "libzvbi_teletextdec",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption options[]

Definition at line 557 of file libzvbi-teletextdec.c.

◆ ff_libzvbi_teletext_decoder

AVCodec ff_libzvbi_teletext_decoder
Initial value:
= {
.name = "libzvbi_teletextdec",
.long_name = NULL_IF_CONFIG_SMALL("Libzvbi DVB teletext decoder"),
.priv_data_size = sizeof(TeletextContext),
.capabilities = AV_CODEC_CAP_DELAY,
.priv_class= &teletext_class,
.wrapper_name = "libzvbi",
}
static void flush(AVCodecContext *avctx)
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:984
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static void teletext_flush(AVCodecContext *avctx)
static int teletext_close_decoder(AVCodecContext *avctx)
static int teletext_init_decoder(AVCodecContext *avctx)
static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt)
static const AVClass teletext_class

Definition at line 564 of file libzvbi-teletextdec.c.