FFmpeg
Data Structures | Macros | Functions | Variables
dvdsubdec.c File Reference
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "libavutil/attributes.h"
#include "libavutil/colorspace.h"
#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/bswap.h"

Go to the source code of this file.

Data Structures

struct  DVDSubContext
 

Macros

#define READ_OFFSET(a)   (big_offsets ? AV_RB32(a) : AV_RB16(a))
 
#define OFFSET(field)   offsetof(DVDSubContext, field)
 
#define SD   AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
 

Functions

static void yuv_a_to_rgba (const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
 
static int decode_run_2bit (GetBitContext *gb, int *color)
 
static int decode_run_8bit (GetBitContext *gb, int *color)
 
static int decode_rle (uint8_t *bitmap, int linesize, int w, int h, uint8_t used_color[256], const uint8_t *buf, int start, int buf_size, int is_8bit)
 
static void guess_palette (DVDSubContext *ctx, uint32_t *rgba_palette, uint32_t subtitle_color)
 
static void reset_rects (AVSubtitle *sub_header)
 
static int decode_dvd_subtitles (DVDSubContext *ctx, AVSubtitle *sub_header, const uint8_t *buf, int buf_size)
 
static int is_transp (const uint8_t *buf, int pitch, int n, const uint8_t *transp_color)
 
static int find_smallest_bounding_rectangle (DVDSubContext *ctx, AVSubtitle *s)
 
static int append_to_cached_buf (AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 
static int dvdsub_decode (AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
 
static int parse_ifo_palette (DVDSubContext *ctx, char *p)
 
static int dvdsub_parse_extradata (AVCodecContext *avctx)
 
static av_cold int dvdsub_init (AVCodecContext *avctx)
 
static void dvdsub_flush (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass dvdsub_class
 
const AVCodec ff_dvdsub_decoder
 

Macro Definition Documentation

◆ READ_OFFSET

#define READ_OFFSET (   a)    (big_offsets ? AV_RB32(a) : AV_RB16(a))

Definition at line 218 of file dvdsubdec.c.

◆ OFFSET

#define OFFSET (   field)    offsetof(DVDSubContext, field)

Definition at line 742 of file dvdsubdec.c.

◆ SD

Definition at line 743 of file dvdsubdec.c.

Function Documentation

◆ yuv_a_to_rgba()

static void yuv_a_to_rgba ( const uint8_t *  ycbcr,
const uint8_t *  alpha,
uint32_t *  rgba,
int  num_values 
)
static

Definition at line 50 of file dvdsubdec.c.

Referenced by decode_dvd_subtitles().

◆ decode_run_2bit()

static int decode_run_2bit ( GetBitContext gb,
int color 
)
static

Definition at line 67 of file dvdsubdec.c.

Referenced by decode_rle().

◆ decode_run_8bit()

static int decode_run_8bit ( GetBitContext gb,
int color 
)
static

Definition at line 81 of file dvdsubdec.c.

Referenced by decode_rle().

◆ decode_rle()

static int decode_rle ( uint8_t *  bitmap,
int  linesize,
int  w,
int  h,
uint8_t  used_color[256],
const uint8_t *  buf,
int  start,
int  buf_size,
int  is_8bit 
)
static

Definition at line 100 of file dvdsubdec.c.

Referenced by decode_dvd_subtitles().

◆ guess_palette()

static void guess_palette ( DVDSubContext ctx,
uint32_t *  rgba_palette,
uint32_t  subtitle_color 
)
static

Definition at line 146 of file dvdsubdec.c.

Referenced by decode_dvd_subtitles().

◆ reset_rects()

static void reset_rects ( AVSubtitle sub_header)
static

Definition at line 203 of file dvdsubdec.c.

Referenced by decode_dvd_subtitles(), and dvdsub_decode().

◆ decode_dvd_subtitles()

static int decode_dvd_subtitles ( DVDSubContext ctx,
AVSubtitle sub_header,
const uint8_t *  buf,
int  buf_size 
)
static

Definition at line 220 of file dvdsubdec.c.

Referenced by dvdsub_decode().

◆ is_transp()

static int is_transp ( const uint8_t *  buf,
int  pitch,
int  n,
const uint8_t *  transp_color 
)
static

Definition at line 429 of file dvdsubdec.c.

Referenced by find_smallest_bounding_rectangle().

◆ find_smallest_bounding_rectangle()

static int find_smallest_bounding_rectangle ( DVDSubContext ctx,
AVSubtitle s 
)
static

Definition at line 442 of file dvdsubdec.c.

Referenced by dvdsub_decode().

◆ append_to_cached_buf()

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

Definition at line 533 of file dvdsubdec.c.

Referenced by dvdsub_decode().

◆ dvdsub_decode()

static int dvdsub_decode ( AVCodecContext avctx,
void *  data,
int data_size,
AVPacket avpkt 
)
static

Definition at line 550 of file dvdsubdec.c.

◆ parse_ifo_palette()

static int parse_ifo_palette ( DVDSubContext ctx,
char *  p 
)
static

Definition at line 610 of file dvdsubdec.c.

Referenced by dvdsub_init().

◆ dvdsub_parse_extradata()

static int dvdsub_parse_extradata ( AVCodecContext avctx)
static

Definition at line 670 of file dvdsubdec.c.

Referenced by dvdsub_init().

◆ dvdsub_init()

static av_cold int dvdsub_init ( AVCodecContext avctx)
static

Definition at line 711 of file dvdsubdec.c.

◆ dvdsub_flush()

static void dvdsub_flush ( AVCodecContext avctx)
static

Definition at line 736 of file dvdsubdec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "palette", "set the global palette", OFFSET(palette_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD },
{ "ifo_palette", "obtain the global palette from .IFO file", OFFSET(ifo_str), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, SD },
{ "forced_subs_only", "Only show forced subtitles", OFFSET(forced_subs_only), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SD},
{ NULL }
}

Definition at line 744 of file dvdsubdec.c.

◆ dvdsub_class

const AVClass dvdsub_class
static
Initial value:
= {
.class_name = "dvdsubdec",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 750 of file dvdsubdec.c.

◆ ff_dvdsub_decoder

const AVCodec ff_dvdsub_decoder
Initial value:
= {
.name = "dvdsub",
.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
.priv_data_size = sizeof(DVDSubContext),
.priv_class = &dvdsub_class,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 757 of file dvdsubdec.c.

options
static const AVOption options[]
Definition: dvdsubdec.c:744
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
dvdsub_init
static av_cold int dvdsub_init(AVCodecContext *avctx)
Definition: dvdsubdec.c:711
dvdsub_flush
static void dvdsub_flush(AVCodecContext *avctx)
Definition: dvdsubdec.c:736
SD
#define SD
Definition: dvdsubdec.c:743
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
DVDSubContext
Definition: dvdsubdec.c:32
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:593
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_DVD_SUBTITLE
@ AV_CODEC_ID_DVD_SUBTITLE
Definition: codec_id.h:521
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
dvdsub_class
static const AVClass dvdsub_class
Definition: dvdsubdec.c:750
OFFSET
#define OFFSET(field)
Definition: dvdsubdec.c:742
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
dvdsub_decode
static int dvdsub_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: dvdsubdec.c:550