[FFmpeg-devel] [PATCH 1/4] avformat/assdec: UTF-16 support
wm4
nfxjfg at googlemail.com
Wed Sep 3 00:21:25 CEST 2014
On Tue, 2 Sep 2014 23:18:02 +0200
Clément Bœsch <u at pkh.me> wrote:
> 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.
Sure. I didn't do it because all magic numbers are used in one place,
but ok.
> [...]
>
> Apart from that, patch looks really good to me. I'll review the rest of
> the patchset in a moment.
>
More information about the ffmpeg-devel
mailing list