Changeset bd57eaaeb3001b9e2af467053bd55f5f15b2a7ea
- Timestamp:
- 02/05/08 08:29:23
(5 months ago)
- Author:
- Jean-Baptiste Kempf <jb@videolan.org>
- git-committer:
- Jean-Baptiste Kempf <jb@videolan.org> 1209709763 -0700
- git-parent:
[beee3221da8d2f81ff6142269d875ea59e6fd5f3]
- git-author:
- Jean-Baptiste Kempf <jb@videolan.org> 1209709763 -0700
- Message:
Support for AQT subtitles.
Parsing is fine but timing is wrong since it must be multiplied by FPS.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r57bbabb |
rbd57eaa |
|
| 100 | 100 | SUB_TYPE_SUBVIEWER, |
|---|
| 101 | 101 | SUB_TYPE_DVDSUBTITLE, |
|---|
| 102 | | SUB_TYPE_MPL2 |
|---|
| | 102 | SUB_TYPE_MPL2, |
|---|
| | 103 | SUB_TYPE_AQT |
|---|
| 103 | 104 | }; |
|---|
| 104 | 105 | |
|---|
| … | … | |
| 146 | 147 | static int ParseDVDSubtitle( demux_t *, subtitle_t *, int ); |
|---|
| 147 | 148 | static int ParseMPL2 ( demux_t *, subtitle_t *, int ); |
|---|
| | 149 | static int ParseAQT ( demux_t *, subtitle_t *, int ); |
|---|
| 148 | 150 | |
|---|
| 149 | 151 | static struct |
|---|
| … | … | |
| 165 | 167 | { "dvdsubtitle",SUB_TYPE_DVDSUBTITLE, "DVDSubtitle", ParseDVDSubtitle }, |
|---|
| 166 | 168 | { "mpl2", SUB_TYPE_MPL2, "MPL2", ParseMPL2 }, |
|---|
| | 169 | { "aqt", SUB_TYPE_AQT, "AQTitle", ParseAQT }, |
|---|
| 167 | 170 | { NULL, SUB_TYPE_UNKNOWN, "Unknown", NULL } |
|---|
| 168 | 171 | }; |
|---|
| … | … | |
| 318 | 321 | p_sys->i_type = SUB_TYPE_MPL2; |
|---|
| 319 | 322 | break; |
|---|
| | 323 | }else if( sscanf (s, "-->> %d", &i_dummy) == 1 ) |
|---|
| | 324 | { |
|---|
| | 325 | p_sys->i_type = SUB_TYPE_AQT; |
|---|
| 320 | 326 | } |
|---|
| 321 | 327 | |
|---|
| … | … | |
| 1227 | 1233 | } |
|---|
| 1228 | 1234 | |
|---|
| | 1235 | static int ParseAQT( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx ) |
|---|
| | 1236 | { |
|---|
| | 1237 | demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| | 1238 | text_t *txt = &p_sys->txt; |
|---|
| | 1239 | char *psz_text = strdup( "" ); |
|---|
| | 1240 | int i_old = 0; |
|---|
| | 1241 | int i_firstline = 1; |
|---|
| | 1242 | |
|---|
| | 1243 | for( ;; ) |
|---|
| | 1244 | { |
|---|
| | 1245 | int t; /* Time */ |
|---|
| | 1246 | |
|---|
| | 1247 | const char *s = TextGetLine( txt ); |
|---|
| | 1248 | |
|---|
| | 1249 | if( !s ) |
|---|
| | 1250 | return VLC_EGENERIC; |
|---|
| | 1251 | |
|---|
| | 1252 | /* Data Lines */ |
|---|
| | 1253 | if( sscanf (s, "-->> %d", &t) == 1) |
|---|
| | 1254 | { |
|---|
| | 1255 | p_subtitle->i_start = (int64_t)t; /* * FPS*/ |
|---|
| | 1256 | p_subtitle->i_stop = 0; |
|---|
| | 1257 | |
|---|
| | 1258 | /* Starting of a subtitle */ |
|---|
| | 1259 | if( i_firstline ) |
|---|
| | 1260 | { |
|---|
| | 1261 | i_firstline = 0; |
|---|
| | 1262 | } |
|---|
| | 1263 | /* We have been too far: end of the subtitle, begin of next */ |
|---|
| | 1264 | else |
|---|
| | 1265 | { |
|---|
| | 1266 | txt->i_line--; |
|---|
| | 1267 | break; |
|---|
| | 1268 | } |
|---|
| | 1269 | } |
|---|
| | 1270 | /* Text Lines */ |
|---|
| | 1271 | else |
|---|
| | 1272 | { |
|---|
| | 1273 | i_old = strlen( psz_text ) + 1; |
|---|
| | 1274 | psz_text = realloc( psz_text, i_old + strlen( s ) + 1 ); |
|---|
| | 1275 | if( !psz_text ) |
|---|
| | 1276 | return VLC_ENOMEM; |
|---|
| | 1277 | strcat( psz_text, s ); |
|---|
| | 1278 | strcat( psz_text, "\n" ); |
|---|
| | 1279 | if( txt->i_line == txt->i_line_count ) |
|---|
| | 1280 | break; |
|---|
| | 1281 | } |
|---|
| | 1282 | } |
|---|
| | 1283 | p_subtitle->psz_text = psz_text; |
|---|
| | 1284 | return VLC_SUCCESS; |
|---|
| | 1285 | } |
|---|
| | 1286 | |
|---|