FFmpeg
Macros | Functions | Variables
xsubenc.c File Reference
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "put_bits.h"

Go to the source code of this file.

Macros

#define PADDING   0
 Number of pixels to pad left and right. More...
 
#define PADDING_COLOR   0
 

Functions

static void put_xsub_rle (PutBitContext *pb, int len, int color)
 Encode a single color run. More...
 
static int xsub_encode_rle (PutBitContext *pb, const uint8_t *bitmap, int linesize, int w, int h)
 Encode a 4-color bitmap with XSUB rle. More...
 
static int make_tc (uint64_t ms, int *tc)
 
static int xsub_encode (AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *h)
 
static av_cold int xsub_encoder_init (AVCodecContext *avctx)
 

Variables

const AVCodec ff_xsub_encoder
 

Macro Definition Documentation

◆ PADDING

#define PADDING   0

Number of pixels to pad left and right.

The official encoder pads the subtitles with two pixels on either side, but until we find out why, we won't do it (we will pad to have width divisible by 2 though).

Definition at line 35 of file xsubenc.c.

◆ PADDING_COLOR

#define PADDING_COLOR   0

Definition at line 36 of file xsubenc.c.

Function Documentation

◆ put_xsub_rle()

static void put_xsub_rle ( PutBitContext pb,
int  len,
int  color 
)
static

Encode a single color run.

At most 16 bits will be used.

Parameters
lenlength of the run, values > 255 mean "until end of line", may not be < 0.
colorcolor to encode, only the lowest two bits are used and all others must be 0.

Definition at line 43 of file xsubenc.c.

Referenced by xsub_encode(), and xsub_encode_rle().

◆ xsub_encode_rle()

static int xsub_encode_rle ( PutBitContext pb,
const uint8_t *  bitmap,
int  linesize,
int  w,
int  h 
)
static

Encode a 4-color bitmap with XSUB rle.

The encoded bitmap may be wider than the source bitmap due to padding.

Definition at line 57 of file xsubenc.c.

Referenced by xsub_encode().

◆ make_tc()

static int make_tc ( uint64_t  ms,
int tc 
)
static

Definition at line 102 of file xsubenc.c.

Referenced by xsub_encode().

◆ xsub_encode()

static int xsub_encode ( AVCodecContext avctx,
unsigned char *  buf,
int  bufsize,
const AVSubtitle h 
)
static

Definition at line 114 of file xsubenc.c.

◆ xsub_encoder_init()

static av_cold int xsub_encoder_init ( AVCodecContext avctx)
static

Definition at line 204 of file xsubenc.c.

Variable Documentation

◆ ff_xsub_encoder

const AVCodec ff_xsub_encoder
Initial value:
= {
.name = "xsub",
.long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
.encode_sub = xsub_encode,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}

Definition at line 214 of file xsubenc.c.

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:41
xsub_encode
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *h)
Definition: xsubenc.c:114
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
xsub_encoder_init
static av_cold int xsub_encoder_init(AVCodecContext *avctx)
Definition: xsubenc.c:204
AV_CODEC_ID_XSUB
@ AV_CODEC_ID_XSUB
Definition: codec_id.h:522