summaryrefslogtreecommitdiff
path: root/ffmpeg/libavformat/subtitles.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavformat/subtitles.h
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavformat/subtitles.h')
-rw-r--r--ffmpeg/libavformat/subtitles.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/ffmpeg/libavformat/subtitles.h b/ffmpeg/libavformat/subtitles.h
index 455b374..b5a96ec 100644
--- a/ffmpeg/libavformat/subtitles.h
+++ b/ffmpeg/libavformat/subtitles.h
@@ -25,11 +25,17 @@
#include "avformat.h"
#include "libavutil/bprint.h"
+enum sub_sort {
+ SUB_SORT_TS_POS = 0, ///< sort by timestamps, then position
+ SUB_SORT_POS_TS, ///< sort by position, then timestamps
+};
+
typedef struct {
AVPacket *subs; ///< array of subtitles packets
int nb_subs; ///< number of subtitles packets
int allocated_size; ///< allocated size for subs
int current_sub_idx; ///< current position for the read packet callback
+ enum sub_sort sort; ///< sort method to use when finalizing subtitles
} FFDemuxSubtitlesQueue;
/**
@@ -96,4 +102,23 @@ const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
*/
void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
+/**
+ * Get the number of characters to increment to jump to the next line, or to
+ * the end of the string.
+ * The function handles the following line breaks schemes:
+ * LF, CRLF (MS), or standalone CR (old MacOS).
+ */
+static av_always_inline int ff_subtitles_next_line(const char *ptr)
+{
+ int n = strcspn(ptr, "\r\n");
+ ptr += n;
+ if (*ptr == '\r') {
+ ptr++;
+ n++;
+ }
+ if (*ptr == '\n')
+ n++;
+ return n;
+}
+
#endif /* AVFORMAT_SUBTITLES_H */