FFmpeg
Data Structures | Macros | Functions | Variables
dvdsubenc.c File Reference
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  DVDSubtitleContext
 

Macros

#define PUTNIBBLE(val)
 
#define OFFSET(x)   offsetof(DVDSubtitleContext, x)
 
#define SE   AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void dvd_encode_rle (uint8_t **pq, const uint8_t *bitmap, int linesize, int w, int h, const int cmap[256])
 
static int color_distance (uint32_t a, uint32_t b)
 
static void count_colors (AVCodecContext *avctx, unsigned hits[33], const AVSubtitleRect *r)
 Count colors used in a rectangle, quantizing alpha and grouping by nearest global palette entry. More...
 
static void select_palette (AVCodecContext *avctx, int out_palette[4], int out_alpha[4], unsigned hits[33])
 
static void build_color_map (AVCodecContext *avctx, int cmap[], const uint32_t palette[], const int out_palette[], unsigned int const out_alpha[])
 
static void copy_rectangle (AVSubtitleRect *dst, AVSubtitleRect *src, int cmap[])
 
static int encode_dvd_subtitles (AVCodecContext *avctx, uint8_t *outbuf, int outbuf_size, const AVSubtitle *h)
 
static int dvdsub_init (AVCodecContext *avctx)
 
static int dvdsub_encode (AVCodecContext *avctx, unsigned char *buf, int buf_size, const AVSubtitle *sub)
 

Variables

static const AVOption options []
 
static const AVClass dvdsubenc_class
 
AVCodec ff_dvdsub_encoder
 

Macro Definition Documentation

◆ PUTNIBBLE

#define PUTNIBBLE (   val)
Value:
do {\
if (ncnt++ & 1)\
*q++ = bitbuf | ((val) & 0x0f);\
else\
bitbuf = (val) << 4;\
} while(0)

Definition at line 36 of file dvdsubenc.c.

◆ OFFSET

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

Definition at line 467 of file dvdsubenc.c.

◆ SE

Definition at line 468 of file dvdsubenc.c.

Function Documentation

◆ dvd_encode_rle()

static void dvd_encode_rle ( uint8_t **  pq,
const uint8_t bitmap,
int  linesize,
int  w,
int  h,
const int  cmap[256] 
)
static

Definition at line 44 of file dvdsubenc.c.

Referenced by encode_dvd_subtitles().

◆ color_distance()

static int color_distance ( uint32_t  a,
uint32_t  b 
)
static

Definition at line 97 of file dvdsubenc.c.

Referenced by build_color_map(), count_colors(), and select_palette().

◆ count_colors()

static void count_colors ( AVCodecContext avctx,
unsigned  hits[33],
const AVSubtitleRect r 
)
static

Count colors used in a rectangle, quantizing alpha and grouping by nearest global palette entry.

Definition at line 116 of file dvdsubenc.c.

Referenced by encode_dvd_subtitles().

◆ select_palette()

static void select_palette ( AVCodecContext avctx,
int  out_palette[4],
int  out_alpha[4],
unsigned  hits[33] 
)
static

Definition at line 153 of file dvdsubenc.c.

Referenced by encode_dvd_subtitles().

◆ build_color_map()

static void build_color_map ( AVCodecContext avctx,
int  cmap[],
const uint32_t  palette[],
const int  out_palette[],
unsigned int const  out_alpha[] 
)
static

Definition at line 211 of file dvdsubenc.c.

Referenced by encode_dvd_subtitles().

◆ copy_rectangle()

static void copy_rectangle ( AVSubtitleRect dst,
AVSubtitleRect src,
int  cmap[] 
)
static

Definition at line 234 of file dvdsubenc.c.

Referenced by encode_dvd_subtitles().

◆ encode_dvd_subtitles()

static int encode_dvd_subtitles ( AVCodecContext avctx,
uint8_t outbuf,
int  outbuf_size,
const AVSubtitle h 
)
static

Definition at line 250 of file dvdsubenc.c.

Referenced by dvdsub_encode().

◆ dvdsub_init()

static int dvdsub_init ( AVCodecContext avctx)
static

Definition at line 426 of file dvdsubenc.c.

◆ dvdsub_encode()

static int dvdsub_encode ( AVCodecContext avctx,
unsigned char *  buf,
int  buf_size,
const AVSubtitle sub 
)
static

Definition at line 456 of file dvdsubenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"even_rows_fix", "Make number of rows even (workaround for some players)", OFFSET(even_rows_fix), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, SE},
{ NULL },
}

Definition at line 469 of file dvdsubenc.c.

◆ dvdsubenc_class

const AVClass dvdsubenc_class
static
Initial value:
= {
.class_name = "VOBSUB subtitle encoder",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 474 of file dvdsubenc.c.

◆ ff_dvdsub_encoder

AVCodec ff_dvdsub_encoder
Initial value:
= {
.name = "dvdsub",
.long_name = NULL_IF_CONFIG_SMALL("DVD subtitles"),
.init = dvdsub_init,
.encode_sub = dvdsub_encode,
.priv_class = &dvdsubenc_class,
.priv_data_size = sizeof(DVDSubtitleContext),
}

Definition at line 481 of file dvdsubenc.c.

options
static const AVOption options[]
Definition: dvdsubenc.c:469
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
dvdsubenc_class
static const AVClass dvdsubenc_class
Definition: dvdsubenc.c:474
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_DVD_SUBTITLE
@ AV_CODEC_ID_DVD_SUBTITLE
Definition: avcodec.h:658
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
dvdsub_encode
static int dvdsub_encode(AVCodecContext *avctx, unsigned char *buf, int buf_size, const AVSubtitle *sub)
Definition: dvdsubenc.c:456
DVDSubtitleContext
Definition: dvdsubenc.c:29
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:188
val
const char const char void * val
Definition: avisynth_c.h:863
SE
#define SE
Definition: dvdsubenc.c:468
dvdsub_init
static int dvdsub_init(AVCodecContext *avctx)
Definition: dvdsubenc.c:426
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:240
OFFSET
#define OFFSET(x)
Definition: dvdsubenc.c:467