* Copyright (c) 2005 DivX, Inc.
* Copyright (c) 2009 Bjorn Axelsson
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define PADDING_COLOR 0
/**
- * Encodes a single color run. At most 16 bits will be used.
- * \param len length of the run, values > 255 mean "until end of line", may not be < 0.
- * \param color color to encode, only the lowest two bits are used and all others must be 0.
+ * Encode a single color run. At most 16 bits will be used.
+ * @param len length of the run, values > 255 mean "until end of line", may not be < 0.
+ * @param color color to encode, only the lowest two bits are used and all others must be 0.
*/
static void put_xsub_rle(PutBitContext *pb, int len, int color)
{
}
/**
- * Encodes a 4-color bitmap with XSUB rle.
+ * Encode a 4-color bitmap with XSUB rle.
*
* The encoded bitmap may be wider than the source bitmap due to padding.
*/
if (color != PADDING_COLOR && (PADDING + (w&1)))
put_xsub_rle(pb, PADDING + (w&1), PADDING_COLOR);
- align_put_bits(pb);
+ avpriv_align_put_bits(pb);
bitmap += linesize;
}
}
static int xsub_encode(AVCodecContext *avctx, unsigned char *buf,
- int bufsize, void *data)
+ int bufsize, const AVSubtitle *h)
{
- AVSubtitle *h = data;
uint64_t startTime = h->pts / 1000; // FIXME: need better solution...
uint64_t endTime = startTime + h->end_display_time - h->start_display_time;
int start_tc[4], end_tc[4];
// Enforce total height to be be multiple of 2
if (h->rects[0]->h & 1) {
put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR);
- align_put_bits(&pb);
+ avpriv_align_put_bits(&pb);
}
flush_put_bits(&pb);
return 0;
}
-AVCodec xsub_encoder = {
- "xsub",
- AVMEDIA_TYPE_SUBTITLE,
- CODEC_ID_XSUB,
- 0,
- xsub_encoder_init,
- xsub_encode,
- NULL,
- .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
+AVCodec ff_xsub_encoder = {
+ .name = "xsub",
+ .type = AVMEDIA_TYPE_SUBTITLE,
+ .id = AV_CODEC_ID_XSUB,
+ .init = xsub_encoder_init,
+ .encode_sub = xsub_encode,
+ .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
};