Changeset b3524a50ba5a2a49ae4dca4faccd24d2266c34e3
- Timestamp:
- 05/13/08 21:42:51
(2 months ago)
- Author:
- Jean-Baptiste Kempf <jb@videolan.org>
- git-committer:
- Jean-Baptiste Kempf <jb@videolan.org> 1210707771 -0700
- git-parent:
[7b12ac8c3cfbb95f2091775a414c5898edad335f]
- git-author:
- Jean-Baptiste Kempf <jb@videolan.org> 1210707771 -0700
- Message:
Support for parsing PowerDivx? (.psb) subtitles
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r6ba2378 |
rb3524a5 |
|
| 108 | 108 | SUB_TYPE_PJS, |
|---|
| 109 | 109 | SUB_TYPE_MPSUB, |
|---|
| 110 | | SUB_TYPE_JACOSUB |
|---|
| | 110 | SUB_TYPE_JACOSUB, |
|---|
| | 111 | SUB_TYPE_PSB |
|---|
| 111 | 112 | }; |
|---|
| 112 | 113 | |
|---|
| … | … | |
| 159 | 160 | static int ParseMPSub ( demux_t *, subtitle_t *, int ); |
|---|
| 160 | 161 | static int ParseJSS ( demux_t *, subtitle_t *, int ); |
|---|
| | 162 | static int ParsePSB ( demux_t *, subtitle_t *, int ); |
|---|
| 161 | 163 | |
|---|
| 162 | 164 | static struct |
|---|
| … | … | |
| 182 | 184 | { "mpsub", SUB_TYPE_MPSUB, "MPSub", ParseMPSub }, |
|---|
| 183 | 185 | { "jacosub", SUB_TYPE_JACOSUB, "JacoSub", ParseJSS }, |
|---|
| | 186 | { "psb", SUB_TYPE_PSB, "PowerDivx", ParsePSB }, |
|---|
| 184 | 187 | { NULL, SUB_TYPE_UNKNOWN, "Unknown", NULL } |
|---|
| 185 | 188 | }; |
|---|
| … | … | |
| 366 | 369 | { |
|---|
| 367 | 370 | p_sys->i_type = SUB_TYPE_PJS; |
|---|
| | 371 | } |
|---|
| | 372 | else if( sscanf( s, "{%d:%d:%d}", &i_dummy, &i_dummy, &i_dummy ) == 3 ) |
|---|
| | 373 | { |
|---|
| | 374 | p_sys->i_type = SUB_TYPE_PSB; |
|---|
| 368 | 375 | } |
|---|
| 369 | 376 | |
|---|
| … | … | |
| 1003 | 1010 | * h:m:s Line1|Line2|Line3.... |
|---|
| 1004 | 1011 | */ |
|---|
| 1005 | | static int ParseVplayer( demux_t *p_demux, subtitle_t *p_subtitle, |
|---|
| | 1012 | static int ParseVplayer( demux_t *p_demux, subtitle_t *p_subtitle, |
|---|
| 1006 | 1013 | int i_idx ) |
|---|
| 1007 | 1014 | { |
|---|
| … | … | |
| 1679 | 1686 | } |
|---|
| 1680 | 1687 | |
|---|
| | 1688 | static int ParsePSB( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) |
|---|
| | 1689 | { |
|---|
| | 1690 | VLC_UNUSED( i_idx ); |
|---|
| | 1691 | |
|---|
| | 1692 | demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| | 1693 | text_t *txt = &p_sys->txt; |
|---|
| | 1694 | char *psz_text; |
|---|
| | 1695 | int i; |
|---|
| | 1696 | |
|---|
| | 1697 | for( ;; ) |
|---|
| | 1698 | { |
|---|
| | 1699 | int h1, m1, s1; |
|---|
| | 1700 | int h2, m2, s2; |
|---|
| | 1701 | const char *s = TextGetLine( txt ); |
|---|
| | 1702 | |
|---|
| | 1703 | if( !s ) |
|---|
| | 1704 | return VLC_EGENERIC; |
|---|
| | 1705 | |
|---|
| | 1706 | psz_text = malloc( strlen( s ) + 1 ); |
|---|
| | 1707 | if( !psz_text ) |
|---|
| | 1708 | return VLC_ENOMEM; |
|---|
| | 1709 | |
|---|
| | 1710 | if( sscanf( s, "{%d:%d:%d}{%d:%d:%d}%[^\r\n]", |
|---|
| | 1711 | &h1, &m1, &s1, &h2, &m2, &s2, psz_text ) == 7 ) |
|---|
| | 1712 | { |
|---|
| | 1713 | p_subtitle->i_start = ( (int64_t)h1 * 3600*1000 + |
|---|
| | 1714 | (int64_t)m1 * 60*1000 + |
|---|
| | 1715 | (int64_t)s1 * 1000 ) * 1000; |
|---|
| | 1716 | p_subtitle->i_stop = ( (int64_t)h2 * 3600*1000 + |
|---|
| | 1717 | (int64_t)m2 * 60*1000 + |
|---|
| | 1718 | (int64_t)s2 * 1000 ) * 1000; |
|---|
| | 1719 | break; |
|---|
| | 1720 | } |
|---|
| | 1721 | free( psz_text ); |
|---|
| | 1722 | } |
|---|
| | 1723 | |
|---|
| | 1724 | /* replace | by \n */ |
|---|
| | 1725 | for( i = 0; psz_text[i] != '\0'; i++ ) |
|---|
| | 1726 | { |
|---|
| | 1727 | if( psz_text[i] == '|' ) |
|---|
| | 1728 | psz_text[i] = '\n'; |
|---|
| | 1729 | } |
|---|
| | 1730 | p_subtitle->psz_text = psz_text; |
|---|
| | 1731 | return VLC_SUCCESS; |
|---|
| | 1732 | } |
|---|
| | 1733 | |
|---|
| | 1734 | |
|---|