FFmpeg
Data Structures | Macros | Functions | Variables
dvbsubdec.c File Reference
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"

Go to the source code of this file.

Data Structures

struct  DVBSubCLUT
 
struct  DVBSubObjectDisplay
 
struct  DVBSubObject
 
struct  DVBSubRegionDisplay
 
struct  DVBSubRegion
 
struct  DVBSubDisplayDefinition
 
struct  DVBSubContext
 

Macros

#define DVBSUB_PAGE_SEGMENT   0x10
 
#define DVBSUB_REGION_SEGMENT   0x11
 
#define DVBSUB_CLUT_SEGMENT   0x12
 
#define DVBSUB_OBJECT_SEGMENT   0x13
 
#define DVBSUB_DISPLAYDEFINITION_SEGMENT   0x14
 
#define DVBSUB_DISPLAY_SEGMENT   0x80
 
#define cm   (ff_crop_tab + MAX_NEG_CROP)
 
#define RGBA(r, g, b, a)   (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
 
#define V(x, y)   rect->data[0][(x) + (y)*stride]
 
#define L(x, y)   list[d[(x) + (y)*stride]]
 
#define DS   AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
 
#define OFFSET(x)   offsetof(DVBSubContext, x)
 

Functions

static DVBSubObjectget_object (DVBSubContext *ctx, int object_id)
 
static DVBSubCLUTget_clut (DVBSubContext *ctx, int clut_id)
 
static DVBSubRegionget_region (DVBSubContext *ctx, int region_id)
 
static void delete_region_display_list (DVBSubContext *ctx, DVBSubRegion *region)
 
static void delete_cluts (DVBSubContext *ctx)
 
static void delete_objects (DVBSubContext *ctx)
 
static void delete_regions (DVBSubContext *ctx)
 
static av_cold void init_default_clut (void)
 
static av_cold int dvbsub_init_decoder (AVCodecContext *avctx)
 
static av_cold int dvbsub_close_decoder (AVCodecContext *avctx)
 
static int dvbsub_read_2bit_string (AVCodecContext *avctx, uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table, int x_pos)
 
static int dvbsub_read_4bit_string (AVCodecContext *avctx, uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table, int x_pos)
 
static int dvbsub_read_8bit_string (AVCodecContext *avctx, uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, int non_mod, uint8_t *map_table, int x_pos)
 
static void compute_default_clut (DVBSubContext *ctx, uint8_t *clut, AVSubtitleRect *rect, int w, int h)
 
static int save_subtitle_set (AVCodecContext *avctx, AVSubtitle *sub, int *got_output)
 
static void dvbsub_parse_pixel_data_block (AVCodecContext *avctx, DVBSubObjectDisplay *display, const uint8_t *buf, int buf_size, int top_bottom, int non_mod)
 
static int dvbsub_parse_object_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static int dvbsub_parse_clut_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static int dvbsub_parse_region_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static int dvbsub_parse_page_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
 
static int dvbsub_parse_display_definition_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static int dvbsub_display_end_segment (AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
 
static int dvbsub_decode (AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
 

Variables

static DVBSubCLUT default_clut
 
static const AVOption options []
 
static const AVClass dvbsubdec_class
 
const FFCodec ff_dvbsub_decoder
 

Macro Definition Documentation

◆ DVBSUB_PAGE_SEGMENT

#define DVBSUB_PAGE_SEGMENT   0x10

Definition at line 33 of file dvbsubdec.c.

◆ DVBSUB_REGION_SEGMENT

#define DVBSUB_REGION_SEGMENT   0x11

Definition at line 34 of file dvbsubdec.c.

◆ DVBSUB_CLUT_SEGMENT

#define DVBSUB_CLUT_SEGMENT   0x12

Definition at line 35 of file dvbsubdec.c.

◆ DVBSUB_OBJECT_SEGMENT

#define DVBSUB_OBJECT_SEGMENT   0x13

Definition at line 36 of file dvbsubdec.c.

◆ DVBSUB_DISPLAYDEFINITION_SEGMENT

#define DVBSUB_DISPLAYDEFINITION_SEGMENT   0x14

Definition at line 37 of file dvbsubdec.c.

◆ DVBSUB_DISPLAY_SEGMENT

#define DVBSUB_DISPLAY_SEGMENT   0x80

Definition at line 38 of file dvbsubdec.c.

◆ cm

#define cm   (ff_crop_tab + MAX_NEG_CROP)

Definition at line 40 of file dvbsubdec.c.

◆ RGBA

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

Definition at line 42 of file dvbsubdec.c.

◆ V

#define V (   x,
 
)    rect->data[0][(x) + (y)*stride]

◆ L

#define L (   x,
 
)    list[d[(x) + (y)*stride]]

◆ DS

Definition at line 1558 of file dvbsubdec.c.

◆ OFFSET

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

Definition at line 1559 of file dvbsubdec.c.

Function Documentation

◆ get_object()

static DVBSubObject* get_object ( DVBSubContext ctx,
int  object_id 
)
static

◆ get_clut()

static DVBSubCLUT* get_clut ( DVBSubContext ctx,
int  clut_id 
)
static

Definition at line 156 of file dvbsubdec.c.

Referenced by dvbsub_parse_clut_segment(), and save_subtitle_set().

◆ get_region()

static DVBSubRegion* get_region ( DVBSubContext ctx,
int  region_id 
)
static

◆ delete_region_display_list()

static void delete_region_display_list ( DVBSubContext ctx,
DVBSubRegion region 
)
static

Definition at line 178 of file dvbsubdec.c.

Referenced by delete_regions(), and dvbsub_parse_region_segment().

◆ delete_cluts()

static void delete_cluts ( DVBSubContext ctx)
static

Definition at line 224 of file dvbsubdec.c.

Referenced by dvbsub_close_decoder(), and dvbsub_parse_page_segment().

◆ delete_objects()

static void delete_objects ( DVBSubContext ctx)
static

Definition at line 235 of file dvbsubdec.c.

Referenced by dvbsub_close_decoder(), and dvbsub_parse_page_segment().

◆ delete_regions()

static void delete_regions ( DVBSubContext ctx)
static

Definition at line 246 of file dvbsubdec.c.

Referenced by dvbsub_close_decoder(), and dvbsub_parse_page_segment().

◆ init_default_clut()

static av_cold void init_default_clut ( void  )
static

Definition at line 260 of file dvbsubdec.c.

Referenced by dvbsub_init_decoder().

◆ dvbsub_init_decoder()

static av_cold int dvbsub_init_decoder ( AVCodecContext avctx)
static

Definition at line 325 of file dvbsubdec.c.

◆ dvbsub_close_decoder()

static av_cold int dvbsub_close_decoder ( AVCodecContext avctx)
static

Definition at line 356 of file dvbsubdec.c.

◆ dvbsub_read_2bit_string()

static int dvbsub_read_2bit_string ( AVCodecContext avctx,
uint8_t *  destbuf,
int  dbuf_len,
const uint8_t **  srcbuf,
int  buf_size,
int  non_mod,
uint8_t *  map_table,
int  x_pos 
)
static

Definition at line 379 of file dvbsubdec.c.

Referenced by dvbsub_parse_pixel_data_block().

◆ dvbsub_read_4bit_string()

static int dvbsub_read_4bit_string ( AVCodecContext avctx,
uint8_t *  destbuf,
int  dbuf_len,
const uint8_t **  srcbuf,
int  buf_size,
int  non_mod,
uint8_t *  map_table,
int  x_pos 
)
static

Definition at line 487 of file dvbsubdec.c.

Referenced by dvbsub_parse_pixel_data_block().

◆ dvbsub_read_8bit_string()

static int dvbsub_read_8bit_string ( AVCodecContext avctx,
uint8_t *  destbuf,
int  dbuf_len,
const uint8_t **  srcbuf,
int  buf_size,
int  non_mod,
uint8_t *  map_table,
int  x_pos 
)
static

Definition at line 610 of file dvbsubdec.c.

Referenced by dvbsub_parse_pixel_data_block().

◆ compute_default_clut()

static void compute_default_clut ( DVBSubContext ctx,
uint8_t *  clut,
AVSubtitleRect rect,
int  w,
int  h 
)
static

Definition at line 664 of file dvbsubdec.c.

Referenced by save_subtitle_set().

◆ save_subtitle_set()

static int save_subtitle_set ( AVCodecContext avctx,
AVSubtitle sub,
int *  got_output 
)
static

Definition at line 730 of file dvbsubdec.c.

Referenced by dvbsub_display_end_segment(), and dvbsub_parse_page_segment().

◆ dvbsub_parse_pixel_data_block()

static void dvbsub_parse_pixel_data_block ( AVCodecContext avctx,
DVBSubObjectDisplay display,
const uint8_t *  buf,
int  buf_size,
int  top_bottom,
int  non_mod 
)
static

Definition at line 864 of file dvbsubdec.c.

Referenced by dvbsub_parse_object_segment().

◆ dvbsub_parse_object_segment()

static int dvbsub_parse_object_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 982 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_parse_clut_segment()

static int dvbsub_parse_clut_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 1046 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_parse_region_segment()

static int dvbsub_parse_region_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 1143 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_parse_page_segment()

static int dvbsub_parse_page_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size,
AVSubtitle sub,
int *  got_output 
)
static

Definition at line 1291 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_parse_display_definition_segment()

static int dvbsub_parse_display_definition_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 1385 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_display_end_segment()

static int dvbsub_display_end_segment ( AVCodecContext avctx,
const uint8_t *  buf,
int  buf_size,
AVSubtitle sub,
int *  got_output 
)
static

Definition at line 1432 of file dvbsubdec.c.

Referenced by dvbsub_decode().

◆ dvbsub_decode()

static int dvbsub_decode ( AVCodecContext avctx,
AVSubtitle sub,
int *  got_sub_ptr,
const AVPacket avpkt 
)
static

Definition at line 1442 of file dvbsubdec.c.

Variable Documentation

◆ default_clut

DVBSubCLUT default_clut
static

Definition at line 55 of file dvbsubdec.c.

Referenced by dvbsub_parse_clut_segment(), init_default_clut(), and save_subtitle_set().

◆ options

const AVOption options[]
static
Initial value:
= {
{"compute_edt", "compute end of time using pts or timeout", OFFSET(compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
{"compute_clut", "compute clut when not available(-1) or only once (-2) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -2, 1, DS},
{"dvb_substream", "", OFFSET(substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
{NULL}
}

Definition at line 1560 of file dvbsubdec.c.

◆ dvbsubdec_class

const AVClass dvbsubdec_class
static
Initial value:
= {
.class_name = "DVB Sub Decoder",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 1566 of file dvbsubdec.c.

◆ ff_dvbsub_decoder

const FFCodec ff_dvbsub_decoder
Initial value:
= {
.p.name = "dvbsub",
CODEC_LONG_NAME("DVB subtitles"),
.priv_data_size = sizeof(DVBSubContext),
.p.priv_class = &dvbsubdec_class,
}

Definition at line 1573 of file dvbsubdec.c.

AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
dvbsubdec_class
static const AVClass dvbsubdec_class
Definition: dvbsubdec.c:1566
options
static const AVOption options[]
Definition: dvbsubdec.c:1560
OFFSET
#define OFFSET(x)
Definition: dvbsubdec.c:1559
AV_CODEC_ID_DVB_SUBTITLE
@ AV_CODEC_ID_DVB_SUBTITLE
Definition: codec_id.h:557
dvbsub_decode
static int dvbsub_decode(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Definition: dvbsubdec.c:1442
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
dvbsub_close_decoder
static av_cold int dvbsub_close_decoder(AVCodecContext *avctx)
Definition: dvbsubdec.c:356
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
dvbsub_init_decoder
static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
Definition: dvbsubdec.c:325
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
DS
#define DS
Definition: dvbsubdec.c:1558
FF_CODEC_DECODE_SUB_CB
#define FF_CODEC_DECODE_SUB_CB(func)
Definition: codec_internal.h:314
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
DVBSubContext
Definition: dvbsubdec.c:123