[FFmpeg-devel] [PATCH 1/4] avformat/assdec: UTF-16 support
Clément Bœsch
u at pkh.me
Tue Sep 2 23:18:02 CEST 2014
On Tue, Sep 02, 2014 at 08:56:09PM +0200, wm4 wrote:
> Use the UTF-16 BOM to detect UTF-16 encoding. Convert the file contents
> to UTF-8 on the fly using FFTextReader, which acts as converting wrapper
> around AVIOContext. It also can work on a static buffer, needed for
> format probing. The FFTextReader wrapper now also takes care of skipping
> the UTF-8 BOM.
> ---
> libavformat/assdec.c | 19 +++++++++------
> libavformat/subtitles.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/subtitles.h | 51 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 126 insertions(+), 7 deletions(-)
>
[...]
> +void ff_text_init_avio(FFTextReader *r, AVIOContext *pb)
> +{
> + int i;
> + r->pb = pb;
> + r->buf_pos = r->buf_len = 0;
> + r->type = 0;
> + for (i = 0; i < 2; i++)
> + r->buf[r->buf_len++] = avio_r8(r->pb);
> + if (strncmp("\xFF\xFE", r->buf, 2) == 0) {
> + r->type = 1; // UTF16LE
Would you mind using an enum for type? You won't need these comments
anymore, and the rest of the code will be easier to read.
[...]
Apart from that, patch looks really good to me. I'll review the rest of
the patchset in a moment.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140902/9014a410/attachment.asc>
More information about the ffmpeg-devel
mailing list