FFmpeg
Data Structures | Macros | Functions | Variables
dvdsubenc.c File Reference
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "dvdsub.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 bprint_to_extradata (AVCodecContext *avctx, struct AVBPrint *buf)
 
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
 
const FFCodec 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 38 of file dvdsubenc.c.

◆ OFFSET

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

Definition at line 489 of file dvdsubenc.c.

◆ SE

Definition at line 490 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 46 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 99 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 118 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 155 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 213 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 236 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 252 of file dvdsubenc.c.

Referenced by dvdsub_encode().

◆ bprint_to_extradata()

static int bprint_to_extradata ( AVCodecContext avctx,
struct AVBPrint *  buf 
)
static

Definition at line 421 of file dvdsubenc.c.

Referenced by dvdsub_init().

◆ dvdsub_init()

static int dvdsub_init ( AVCodecContext avctx)
static

Definition at line 444 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 478 of file dvdsubenc.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, SE },
{"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 491 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 497 of file dvdsubenc.c.

◆ ff_dvdsub_encoder

const FFCodec ff_dvdsub_encoder
Initial value:
= {
.p.name = "dvdsub",
CODEC_LONG_NAME("DVD subtitles"),
.init = dvdsub_init,
.p.priv_class = &dvdsubenc_class,
.priv_data_size = sizeof(DVDSubtitleContext),
}

Definition at line 504 of file dvdsubenc.c.

options
static const AVOption options[]
Definition: dvdsubenc.c:491
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
dvdsubenc_class
static const AVClass dvdsubenc_class
Definition: dvdsubenc.c:497
val
static double val(void *priv, double ch)
Definition: aeval.c:78
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
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: codec_id.h:549
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
dvdsub_encode
static int dvdsub_encode(AVCodecContext *avctx, unsigned char *buf, int buf_size, const AVSubtitle *sub)
Definition: dvdsubenc.c:478
FF_CODEC_ENCODE_SUB_CB
#define FF_CODEC_ENCODE_SUB_CB(func)
Definition: codec_internal.h:299
DVDSubtitleContext
Definition: dvdsubenc.c:30
SE
#define SE
Definition: dvdsubenc.c:490
dvdsub_init
static int dvdsub_init(AVCodecContext *avctx)
Definition: dvdsubenc.c:444
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
OFFSET
#define OFFSET(x)
Definition: dvdsubenc.c:489