36#define PADDING_COLOR 0
58 int linesize,
int w,
int h)
62 for (y = 0; y <
h; y++) {
70 color = bitmap[x1++] & 3;
71 while (x1 <
w && (bitmap[x1] & 3) ==
color)
104 static const int tc_divs[3] = { 1000, 60, 60 };
106 for (
i=0;
i<3;
i++) {
107 tc[
i] = ms % tc_divs[
i];
117 uint64_t startTime =
h->pts / 1000;
118 uint64_t endTime = startTime +
h->end_display_time -
h->start_display_time;
119 int start_tc[4], end_tc[4];
120 uint8_t *hdr = buf + 27;
126 if (bufsize < 27 + 7*2 + 4*3) {
132 if (
h->num_rects != 1)
136 if (!
h->rects[0]->data[0] || !
h->rects[0]->data[1]) {
142 if (
h->rects[0]->nb_colors > 4)
143 av_log(avctx,
AV_LOG_WARNING,
"No more than 4 subtitle colors supported (%d found.)\n",
h->rects[0]->nb_colors);
146 if (((uint32_t *)
h->rects[0]->data[1])[0] & 0xff000000)
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 -1);
171 bytestream_put_le16(&hdr,
h->rects[0]->y +
height -1);
178 bytestream_put_be24(&hdr, ((uint32_t *)
h->rects[0]->data[1])[
i]);
184 h->rects[0]->linesize[0] * 2,
185 h->rects[0]->w, (
h->rects[0]->h + 1) >> 1))
190 h->rects[0]->linesize[0] * 2,
191 h->rects[0]->w,
h->rects[0]->h >> 1))
195 if (
h->rects[0]->h & 1) {
const FFCodec ff_xsub_encoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define FF_CODEC_ENCODE_SUB_CB(func)
#define CODEC_LONG_NAME(str)
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const uint8_t ff_log2_tab[256]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
#define MKTAG(a, b, c, d)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static int put_bytes_count(const PutBitContext *s, int round_up)
static int put_bytes_left(const PutBitContext *s, int round_up)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int put_bytes_output(const PutBitContext *s)
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define PADDING
Number of pixels to pad left and right.
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 make_tc(uint64_t ms, int *tc)
static void put_xsub_rle(PutBitContext *pb, int len, int color)
Encode a single color run.
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, int bufsize, const AVSubtitle *h)
static av_cold int xsub_encoder_init(AVCodecContext *avctx)