summaryrefslogtreecommitdiff
path: root/libavformat/subtitles.h
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2014-09-02 20:52:07 +0200
committerClément Bœsch <u@pkh.me>2014-09-05 23:13:07 +0200
commitd658ef18e3d1ebe63a64f404ac4646890ecf02c9 (patch)
tree914ba72abb4caa1ea91dd805493d3e7fa6b9339c /libavformat/subtitles.h
parent3e8426170ce005c111dfcae7982e18b647b7383f (diff)
downloadffmpeg-d658ef18e3d1ebe63a64f404ac4646890ecf02c9.tar.gz
avformat/srtdec: UTF-16 support
Diffstat (limited to 'libavformat/subtitles.h')
-rw-r--r--libavformat/subtitles.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/libavformat/subtitles.h b/libavformat/subtitles.h
index 38502d6f86..cf8c408486 100644
--- a/libavformat/subtitles.h
+++ b/libavformat/subtitles.h
@@ -22,6 +22,7 @@
#define AVFORMAT_SUBTITLES_H
#include <stdint.h>
+#include <stddef.h>
#include "avformat.h"
#include "libavutil/bprint.h"
@@ -81,6 +82,16 @@ int64_t ff_text_pos(FFTextReader *r);
int ff_text_r8(FFTextReader *r);
/**
+ * Return non-zero if EOF was reached.
+ */
+int ff_text_eof(FFTextReader *r);
+
+/**
+ * Like ff_text_r8(), but don't remove the byte from the buffer.
+ */
+int ff_text_peek_r8(FFTextReader *r);
+
+/**
* Read the given number of bytes (in UTF-8). On error or EOF, \0 bytes are
* written.
*/
@@ -144,19 +155,24 @@ int ff_smil_extract_next_chunk(AVIOContext *pb, AVBPrint *buf, char *c);
const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
/**
- * @brief Read a subtitles chunk.
+ * @brief Same as ff_subtitles_read_text_chunk(), but read from an AVIOContext.
+ */
+void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
+
+/**
+ * @brief Read a subtitles chunk from FFTextReader.
*
* A chunk is defined by a multiline "event", ending with a second line break.
* The trailing line breaks are trimmed. CRLF are supported.
* Example: "foo\r\nbar\r\n\r\nnext" will print "foo\r\nbar" into buf, and pb
* will focus on the 'n' of the "next" string.
*
- * @param pb I/O context
+ * @param tr I/O context
* @param buf an initialized buf where the chunk is written
*
* @note buf is cleared before writing into it.
*/
-void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
+void ff_subtitles_read_text_chunk(FFTextReader *tr, AVBPrint *buf);
/**
* Get the number of characters to increment to jump to the next line, or to
@@ -177,4 +193,16 @@ static av_always_inline int ff_subtitles_next_line(const char *ptr)
return n;
}
+/**
+ * Read a line of text. Discards line ending characters.
+ * The function handles the following line breaks schemes:
+ * LF, CRLF (MS), or standalone CR (old MacOS).
+ *
+ * Returns the number of bytes written to buf. Always writes a terminating 0,
+ * similar as with snprintf.
+ *
+ * @note returns a negative error code if a \0 byte is found
+ */
+ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size);
+
#endif /* AVFORMAT_SUBTITLES_H */