aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/samidec.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2014-09-02 20:53:08 +0200
committerClément Bœsch <u@pkh.me>2014-09-05 23:13:07 +0200
commit231a514dd3d246b38d0bf2a400a1759902a6f051 (patch)
tree9adf769211047d5a7b84d7a312673e3f9a20ee11 /libavformat/samidec.c
parentd658ef18e3d1ebe63a64f404ac4646890ecf02c9 (diff)
downloadffmpeg-231a514dd3d246b38d0bf2a400a1759902a6f051.tar.gz
avformat/samidec: UTF-16 support
ff_smil_extract_next_chunk() is still used by RealText.
Diffstat (limited to 'libavformat/samidec.c')
-rw-r--r--libavformat/samidec.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavformat/samidec.c b/libavformat/samidec.c
index 1a12ecad46..4dbf2cf945 100644
--- a/libavformat/samidec.c
+++ b/libavformat/samidec.c
@@ -38,11 +38,12 @@ typedef struct {
static int sami_probe(AVProbeData *p)
{
- const unsigned char *ptr = p->buf;
+ char buf[6];
+ FFTextReader tr;
+ ff_text_init_buf(&tr, p->buf, p->buf_size);
+ ff_text_read(&tr, buf, sizeof(buf));
- if (AV_RB24(ptr) == 0xEFBBBF)
- ptr += 3; /* skip UTF-8 BOM */
- return !strncmp(ptr, "<SAMI>", 6) ? AVPROBE_SCORE_MAX : 0;
+ return !strncmp(buf, "<SAMI>", 6) ? AVPROBE_SCORE_MAX : 0;
}
static int sami_read_header(AVFormatContext *s)
@@ -52,6 +53,8 @@ static int sami_read_header(AVFormatContext *s)
AVBPrint buf, hdr_buf;
char c = 0;
int res = 0, got_first_sync_point = 0;
+ FFTextReader tr;
+ ff_text_init_avio(&tr, s->pb);
if (!st)
return AVERROR(ENOMEM);
@@ -62,10 +65,10 @@ static int sami_read_header(AVFormatContext *s)
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprint_init(&hdr_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
- while (!avio_feof(s->pb)) {
+ while (!ff_text_eof(&tr)) {
AVPacket *sub;
- const int64_t pos = avio_tell(s->pb) - (c != 0);
- int is_sync, n = ff_smil_extract_next_chunk(s->pb, &buf, &c);
+ const int64_t pos = ff_text_pos(&tr) - (c != 0);
+ int is_sync, n = ff_smil_extract_next_text_chunk(&tr, &buf, &c);
if (n == 0)
break;