35 #define PADDING_COLOR 0
57 int linesize,
int w,
int h)
61 for (y = 0; y < h; y++) {
69 color = bitmap[x1++] & 3;
70 while (x1 < w && (bitmap[x1] & 3) == color)
85 len =
FFMIN(len, 255);
103 static const int tc_divs[3] = { 1000, 60, 60 };
105 for (i=0; i<3; i++) {
106 tc[i] = ms % tc_divs[i];
114 int bufsize,
void *
data)
117 uint64_t startTime = h->
pts / 1000;
119 int start_tc[4], end_tc[4];
120 uint8_t *hdr = buf + 27;
126 if (bufsize < 27 + 7*2 + 4*3) {
147 av_log(avctx,
AV_LOG_WARNING,
"Color index 0 is not transparent. Transparency will be messed up.\n");
155 "[%02d:%02d:%02d.%03d-%02d:%02d:%02d.%03d]",
156 start_tc[3], start_tc[2], start_tc[1], start_tc[0],
157 end_tc[3], end_tc[2], end_tc[1], end_tc[0]);
166 bytestream_put_le16(&hdr, width);
167 bytestream_put_le16(&hdr, height);
168 bytestream_put_le16(&hdr, h->
rects[0]->
x);
169 bytestream_put_le16(&hdr, h->
rects[0]->
y);
170 bytestream_put_le16(&hdr, h->
rects[0]->
x + width);
171 bytestream_put_le16(&hdr, h->
rects[0]->
y + height);
178 bytestream_put_be24(&hdr, ((uint32_t *)h->
rects[0]->
pict.
data[1])[i]);
#define PADDING
Number of pixels to pad left and right.
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
static void put_xsub_rle(PutBitContext *pb, int len, int color)
Encode a single color run.
int x
top left corner of pict, undefined when pict is not set
#define AV_LOG_WARNING
Something somehow does not look correct.
int nb_colors
number of colors in pict, undefined when pict is not set
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
const uint8_t ff_log2_tab[256]
int w
width of pict, undefined when pict is not set
static int make_tc(uint64_t ms, int *tc)
uint8_t * data[AV_NUM_DATA_POINTERS]
int h
height of pict, undefined when pict is not set
int y
top left corner of pict, undefined when pict is not set
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
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.
static int put_bits_count(PutBitContext *s)
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
AVPicture pict
data+linesize for the bitmap of this subtitle.
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static av_cold int xsub_encoder_init(AVCodecContext *avctx)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
uint32_t start_display_time
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static const uint8_t color[]
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, int bufsize, void *data)
#define MKTAG(a, b, c, d)