diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-11 13:37:07 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-11 13:37:07 +0000 |
commit | 979c0910567e6019d109c6449862bf5863336262 (patch) | |
tree | b9dcb01cc23c8b4fdfe3f4b3dadfb99508f45ef3 /libavformat | |
parent | 66fc495a10e810aa9d4a69aa273705142c9d7bcc (diff) | |
download | ffmpeg-979c0910567e6019d109c6449862bf5863336262.tar.gz |
add support for ASS like subtitles in Matroska
Originally committed as revision 9593 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroska.c | 2 | ||||
-rw-r--r-- | libavformat/matroskadec.c | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/libavformat/matroska.c b/libavformat/matroska.c index df8d9513ba..bac262841f 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -61,6 +61,8 @@ CodecTags ff_mkv_codec_tags[]={ {"S_TEXT/ASCII" , CODEC_ID_TEXT}, {"S_TEXT/UTF8" , CODEC_ID_TEXT}, + {"S_TEXT/ASS" , CODEC_ID_TEXT}, + {"S_TEXT/SSA" , CODEC_ID_TEXT}, {"S_VOBSUB" , CODEC_ID_DVD_SUBTITLE}, {NULL , CODEC_ID_NONE} diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index a38504def9..4ca2b6a745 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -95,6 +95,7 @@ typedef struct MatroskaAudioTrack { typedef struct MatroskaSubtitleTrack { MatroskaTrack track; + int ass; //.. } MatroskaSubtitleTrack; @@ -2145,6 +2146,13 @@ matroska_read_header (AVFormatContext *s, } } + else if (codec_id == CODEC_ID_TEXT) { + MatroskaSubtitleTrack *subtrack=(MatroskaSubtitleTrack *)track; + if (!strcmp(track->codec_id, "S_TEXT/ASS") || + !strcmp(track->codec_id, "S_TEXT/SSA")) + subtrack->ass = 1; + } + if (codec_id == CODEC_ID_NONE) { av_log(matroska->ctx, AV_LOG_INFO, "Unknown/unsupported CodecID %s.\n", @@ -2430,14 +2438,24 @@ matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, matroska_queue_packet(matroska, pkt); } } else { + int offset = 0; + + if (st->codec->codec_id == CODEC_ID_TEXT + && ((MatroskaSubtitleTrack *)(matroska->tracks[track]))->ass) { + int i; + for (i=0; i<8 && data[slice_offset+offset]; offset++) + if (data[slice_offset+offset] == ',') + i++; + } + pkt = av_mallocz(sizeof(AVPacket)); /* XXX: prevent data copy... */ - if (av_new_packet(pkt, slice_size) < 0) { + if (av_new_packet(pkt, slice_size-offset) < 0) { res = AVERROR_NOMEM; n = laces-1; break; } - memcpy (pkt->data, data+slice_offset, slice_size); + memcpy (pkt->data, data+slice_offset+offset, slice_size-offset); if (n == 0) pkt->flags = is_keyframe; |