diff options
Diffstat (limited to 'src/plugins/old/ebml_extractor.c')
-rw-r--r-- | src/plugins/old/ebml_extractor.c | 509 |
1 files changed, 339 insertions, 170 deletions
diff --git a/src/plugins/old/ebml_extractor.c b/src/plugins/old/ebml_extractor.c index 2d52d90..f7daa9a 100644 --- a/src/plugins/old/ebml_extractor.c +++ b/src/plugins/old/ebml_extractor.c | |||
@@ -18,11 +18,11 @@ | |||
18 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Made by Gabriel Peixoto | 22 | * Made by Gabriel Peixoto |
23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. | 23 | * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin. |
24 | * Nearly complete rewrite by LRN, Copyright (c) 2012 | 24 | * Nearly complete rewrite by LRN, Copyright (c) 2012 |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "extractor.h" | 28 | #include "extractor.h" |
@@ -44,20 +44,25 @@ | |||
44 | struct tm * | 44 | struct tm * |
45 | gmtime_undocumented_64_r (const __time64_t *timer, struct tm *result) | 45 | gmtime_undocumented_64_r (const __time64_t *timer, struct tm *result) |
46 | { | 46 | { |
47 | struct tm *local_result = NULL;//_gmtime64 (timer); | 47 | struct tm *local_result = NULL; // _gmtime64 (timer); |
48 | 48 | ||
49 | if (local_result == NULL || result == NULL) | 49 | if ((local_result == NULL) || (result == NULL) ) |
50 | return NULL; | 50 | return NULL; |
51 | 51 | ||
52 | memcpy (result, local_result, sizeof (*result)); | 52 | memcpy (result, local_result, sizeof (*result)); |
53 | return result; | 53 | return result; |
54 | } | 54 | } |
55 | |||
56 | |||
55 | #endif | 57 | #endif |
56 | 58 | ||
57 | #include "extractor_plugins.h" | 59 | #include "extractor_plugins.h" |
58 | 60 | ||
59 | #define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0) | 61 | #define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, \ |
60 | #define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0) | 62 | "text/plain", s, strlen (s) + 1); } while (0) |
63 | #define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, \ | ||
64 | EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, \ | ||
65 | strlen (s) + 1); } while (0) | ||
61 | 66 | ||
62 | /** | 67 | /** |
63 | * String length limit. The spec does not limit the strings, | 68 | * String length limit. The spec does not limit the strings, |
@@ -162,9 +167,9 @@ struct MatroskaTagMap tag_map[] = { | |||
162 | {"KEYWORDS", EXTRACTOR_METATYPE_KEYWORDS}, | 167 | {"KEYWORDS", EXTRACTOR_METATYPE_KEYWORDS}, |
163 | {"SUMMARY", EXTRACTOR_METATYPE_SUMMARY}, | 168 | {"SUMMARY", EXTRACTOR_METATYPE_SUMMARY}, |
164 | /* | 169 | /* |
165 | SYNOPSIS UTF-8 A description of the story line of the item. | 170 | SYNOPSIS UTF-8 A description of the story line of the item. |
166 | INITIAL_KEY UTF-8 The initial key that a musical track starts in. The format is identical to ID3. | 171 | INITIAL_KEY UTF-8 The initial key that a musical track starts in. The format is identical to ID3. |
167 | PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance". | 172 | PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance". |
168 | LAW_RATING UTF-8 Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo). | 173 | LAW_RATING UTF-8 Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo). |
169 | ICRA binary The ICRA content rating for parental control. (Previously RSACi) | 174 | ICRA binary The ICRA content rating for parental control. (Previously RSACi) |
170 | */ | 175 | */ |
@@ -176,7 +181,7 @@ struct MatroskaTagMap tag_map[] = { | |||
176 | {"DATE_WRITTEN", EXTRACTOR_METATYPE_UNKNOWN_DATE}, | 181 | {"DATE_WRITTEN", EXTRACTOR_METATYPE_UNKNOWN_DATE}, |
177 | {"DATE_PURCHASED", EXTRACTOR_METATYPE_UNKNOWN_DATE}, | 182 | {"DATE_PURCHASED", EXTRACTOR_METATYPE_UNKNOWN_DATE}, |
178 | /* | 183 | /* |
179 | RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". | 184 | RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". |
180 | COMPOSITION_LOCATION UTF-8 Location that the item was originaly designed/written. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". | 185 | COMPOSITION_LOCATION UTF-8 Location that the item was originaly designed/written. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin". |
181 | COMPOSER_NATIONALITY UTF-8 Nationality of the main composer of the item, mostly for classical music. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. | 186 | COMPOSER_NATIONALITY UTF-8 Nationality of the main composer of the item, mostly for classical music. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. |
182 | */ | 187 | */ |
@@ -188,7 +193,7 @@ struct MatroskaTagMap tag_map[] = { | |||
188 | ENCODER UTF-8 The software or hardware used to encode this item. ("LAME" or "XviD") | 193 | ENCODER UTF-8 The software or hardware used to encode this item. ("LAME" or "XviD") |
189 | ENCODER_SETTINGS UTF-8 A list of the settings used for encoding this item. No specific format. | 194 | ENCODER_SETTINGS UTF-8 A list of the settings used for encoding this item. No specific format. |
190 | BPS UTF-8 The average bits per second of the specified item. This is only the data in the Blocks, and excludes headers and any container overhead. | 195 | BPS UTF-8 The average bits per second of the specified item. This is only the data in the Blocks, and excludes headers and any container overhead. |
191 | FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame. | 196 | FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame. |
192 | */ | 197 | */ |
193 | {"BPM", EXTRACTOR_METATYPE_BEATS_PER_MINUTE}, | 198 | {"BPM", EXTRACTOR_METATYPE_BEATS_PER_MINUTE}, |
194 | /* | 199 | /* |
@@ -201,7 +206,7 @@ struct MatroskaTagMap tag_map[] = { | |||
201 | /* | 206 | /* |
202 | MCDI binary This is a binary dump of the TOC of the CDROM that this item was taken from. This holds the same information as the MCDI in ID3. | 207 | MCDI binary This is a binary dump of the TOC of the CDROM that this item was taken from. This holds the same information as the MCDI in ID3. |
203 | ISBN UTF-8 International Standard Book Number | 208 | ISBN UTF-8 International Standard Book Number |
204 | BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier | 209 | BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier |
205 | CATALOG_NUMBER UTF-8 A label-specific string used to identify the release (TIC 01 for example). | 210 | CATALOG_NUMBER UTF-8 A label-specific string used to identify the release (TIC 01 for example). |
206 | LABEL_CODE UTF-8 A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers (only the number is stored). | 211 | LABEL_CODE UTF-8 A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers (only the number is stored). |
207 | LCCN UTF-8 Library of Congress Control Number | 212 | LCCN UTF-8 Library of Congress Control Number |
@@ -281,7 +286,6 @@ enum | |||
281 | MatroskaID_Tracks_Audio_BitDepth = 0x6264, /* not 0, UINT. Bits per sample, mostly used for PCM. */ | 286 | MatroskaID_Tracks_Audio_BitDepth = 0x6264, /* not 0, UINT. Bits per sample, mostly used for PCM. */ |
282 | 287 | ||
283 | 288 | ||
284 | |||
285 | MatroskaID_Tags = 0x1254C367, /* can appear more than once. Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. */ | 289 | MatroskaID_Tags = 0x1254C367, /* can appear more than once. Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. */ |
286 | MatroskaID_Tags_Tag = 0x7373, /* mandatory, can appear more than once. Element containing elements specific to Tracks/Chapters. */ | 290 | MatroskaID_Tags_Tag = 0x7373, /* mandatory, can appear more than once. Element containing elements specific to Tracks/Chapters. */ |
287 | MatroskaID_Tags_Tag_SimpleTag = 0x67C8, /* mandatory, can appear more than once, recursive. Contains general information about the target. */ | 291 | MatroskaID_Tags_Tag_SimpleTag = 0x67C8, /* mandatory, can appear more than once, recursive. Contains general information about the target. */ |
@@ -315,12 +319,14 @@ enum VINTParseMode | |||
315 | */ | 319 | */ |
316 | static ssize_t | 320 | static ssize_t |
317 | VINTparse (struct EXTRACTOR_PluginList *plugin, | 321 | VINTparse (struct EXTRACTOR_PluginList *plugin, |
318 | int64_t * result, enum VINTParseMode mode) | 322 | int64_t *result, enum VINTParseMode mode) |
319 | { | 323 | { |
320 | /* 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 */ | 324 | /* 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 */ |
321 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; | 325 | static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, |
326 | 0x02, 0x01 }; | ||
322 | /* 01111111 00111111 00011111 00001111 00000111 00000011 00000001 00000000 */ | 327 | /* 01111111 00111111 00011111 00001111 00000111 00000011 00000001 00000000 */ |
323 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00 }; | 328 | static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, |
329 | 0x01, 0x00 }; | ||
324 | static const int64_t int_negative_limits[8] = { | 330 | static const int64_t int_negative_limits[8] = { |
325 | -0x00000000000040LL, /* 7-bit integer */ | 331 | -0x00000000000040LL, /* 7-bit integer */ |
326 | -0x00000000002000LL, /* 14-bit integer */ | 332 | -0x00000000002000LL, /* 14-bit integer */ |
@@ -374,13 +380,11 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
374 | * 1-byte integer has 2^7 different values, | 380 | * 1-byte integer has 2^7 different values, |
375 | * 2-byte integer has 2^14 different values, | 381 | * 2-byte integer has 2^14 different values, |
376 | * etc | 382 | * etc |
377 | */ | 383 | *//* |
378 | /* | ||
379 | * Examine the first byte and see how many 0-bytes are at its beginning. | 384 | * Examine the first byte and see how many 0-bytes are at its beginning. |
380 | */ | 385 | */vint_width = 0; |
381 | vint_width = 0; | ||
382 | for (c = 0; c < 8; c++) | 386 | for (c = 0; c < 8; c++) |
383 | if (!(first_byte & mask[c])) | 387 | if (! (first_byte & mask[c])) |
384 | vint_width++; | 388 | vint_width++; |
385 | else | 389 | else |
386 | break; | 390 | break; |
@@ -403,7 +407,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
403 | * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 407 | * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
404 | * 4-bit signed integer: | 408 | * 4-bit signed integer: |
405 | * 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1 | 409 | * 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1 |
406 | * | 410 | * |
407 | * 3 here is 0011b, and -3 is 1101b | 411 | * 3 here is 0011b, and -3 is 1101b |
408 | * However, writing 1101b into int8_t memory location will NOT make | 412 | * However, writing 1101b into int8_t memory location will NOT make |
409 | * the machine interpret it as -3, it will be interpreted as 00001101b, | 413 | * the machine interpret it as -3, it will be interpreted as 00001101b, |
@@ -427,9 +431,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
427 | * which is outside of the signed integer range (remember, we're in 4-bit space here). | 431 | * which is outside of the signed integer range (remember, we're in 4-bit space here). |
428 | * on the other hand, 5 and -3 both are within the range. | 432 | * on the other hand, 5 and -3 both are within the range. |
429 | * 4) if the number does not exceed the signed integer maximum (7), store it as-is | 433 | * 4) if the number does not exceed the signed integer maximum (7), store it as-is |
430 | */ | 434 | */result_u = 0; |
431 | |||
432 | result_u = 0; | ||
433 | /* Copy the extra bytes into a temporary buffer, in the right order */ | 435 | /* Copy the extra bytes into a temporary buffer, in the right order */ |
434 | for (c = 0; c < vint_width; c++) | 436 | for (c = 0; c < vint_width; c++) |
435 | result_u += ((uint64_t) int_bytes[vint_width - c]) << (c * 8); | 437 | result_u += ((uint64_t) int_bytes[vint_width - c]) << (c * 8); |
@@ -439,7 +441,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
439 | { | 441 | { |
440 | case VINT_READ_UINT: | 442 | case VINT_READ_UINT: |
441 | /* Unset the 1-bit marker */ | 443 | /* Unset the 1-bit marker */ |
442 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 444 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
445 | * 8); | ||
443 | memcpy (result, &result_u, sizeof (uint64_t)); | 446 | memcpy (result, &result_u, sizeof (uint64_t)); |
444 | break; | 447 | break; |
445 | case VINT_READ_ID: | 448 | case VINT_READ_ID: |
@@ -449,7 +452,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
449 | break; | 452 | break; |
450 | case VINT_READ_SIZE: | 453 | case VINT_READ_SIZE: |
451 | /* Unset the 1-bit marker */ | 454 | /* Unset the 1-bit marker */ |
452 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 455 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
456 | * 8); | ||
453 | /* Special case: all-1 size means "size is unknown". We indicate this | 457 | /* Special case: all-1 size means "size is unknown". We indicate this |
454 | * in the return value by setting it to UINT64_MAX. | 458 | * in the return value by setting it to UINT64_MAX. |
455 | */ | 459 | */ |
@@ -459,7 +463,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
459 | break; | 463 | break; |
460 | case VINT_READ_SINT: | 464 | case VINT_READ_SINT: |
461 | /* Unset the 1-bit marker */ | 465 | /* Unset the 1-bit marker */ |
462 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8); | 466 | result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width |
467 | * 8); | ||
463 | /* Interpret large values as negative signed values */ | 468 | /* Interpret large values as negative signed values */ |
464 | if (result_u > int_positive_limits[vint_width]) | 469 | if (result_u > int_positive_limits[vint_width]) |
465 | { | 470 | { |
@@ -492,7 +497,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin, | |||
492 | */ | 497 | */ |
493 | static ssize_t | 498 | static ssize_t |
494 | elementRead (struct EXTRACTOR_PluginList *plugin, | 499 | elementRead (struct EXTRACTOR_PluginList *plugin, |
495 | uint32_t *id, int64_t * size) | 500 | uint32_t *id, int64_t *size) |
496 | { | 501 | { |
497 | int64_t tempID; | 502 | int64_t tempID; |
498 | int64_t tempsize; | 503 | int64_t tempsize; |
@@ -519,6 +524,7 @@ elementRead (struct EXTRACTOR_PluginList *plugin, | |||
519 | return id_offset + size_offset; | 524 | return id_offset + size_offset; |
520 | } | 525 | } |
521 | 526 | ||
527 | |||
522 | static ssize_t | 528 | static ssize_t |
523 | idRead (struct EXTRACTOR_PluginList *plugin, | 529 | idRead (struct EXTRACTOR_PluginList *plugin, |
524 | uint64_t length, uint32_t *id) | 530 | uint64_t length, uint32_t *id) |
@@ -537,8 +543,10 @@ idRead (struct EXTRACTOR_PluginList *plugin, | |||
537 | return id_offset; | 543 | return id_offset; |
538 | } | 544 | } |
539 | 545 | ||
546 | |||
540 | static ssize_t | 547 | static ssize_t |
541 | uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result) | 548 | uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, |
549 | uint64_t *result) | ||
542 | { | 550 | { |
543 | size_t c; | 551 | size_t c; |
544 | unsigned char *data; | 552 | unsigned char *data; |
@@ -552,6 +560,7 @@ uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result | |||
552 | return (ssize_t) length; | 560 | return (ssize_t) length; |
553 | } | 561 | } |
554 | 562 | ||
563 | |||
555 | static ssize_t | 564 | static ssize_t |
556 | sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) | 565 | sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) |
557 | { | 566 | { |
@@ -579,6 +588,7 @@ sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result) | |||
579 | return (ssize_t) length; | 588 | return (ssize_t) length; |
580 | } | 589 | } |
581 | 590 | ||
591 | |||
582 | static ssize_t | 592 | static ssize_t |
583 | stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) | 593 | stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) |
584 | { | 594 | { |
@@ -601,8 +611,10 @@ stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result) | |||
601 | return 1; | 611 | return 1; |
602 | } | 612 | } |
603 | 613 | ||
614 | |||
604 | static ssize_t | 615 | static ssize_t |
605 | floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *result) | 616 | floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long |
617 | double *result) | ||
606 | { | 618 | { |
607 | size_t c; | 619 | size_t c; |
608 | unsigned char t[8]; | 620 | unsigned char t[8]; |
@@ -612,7 +624,7 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re | |||
612 | return -1; | 624 | return -1; |
613 | 625 | ||
614 | /* we don't support 10-byte floats, because not all C compilers will guarantee that long double is stored in 10 bytes in a IEEE-conformant format */ | 626 | /* we don't support 10-byte floats, because not all C compilers will guarantee that long double is stored in 10 bytes in a IEEE-conformant format */ |
615 | if (length != 4 && length != 8 /* && length != 10 */) | 627 | if ((length != 4) && (length != 8) /* && length != 10 */) |
616 | return 0; | 628 | return 0; |
617 | 629 | ||
618 | for (c = 0; c < length; c++) | 630 | for (c = 0; c < length; c++) |
@@ -624,14 +636,15 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re | |||
624 | #endif | 636 | #endif |
625 | } | 637 | } |
626 | if (length == 4) | 638 | if (length == 4) |
627 | *result = * ((float *) t); | 639 | *result = *((float *) t); |
628 | else if (length == 8) | 640 | else if (length == 8) |
629 | *result = * ((double *) t); | 641 | *result = *((double *) t); |
630 | else | 642 | else |
631 | *result = * ((long double *) t); | 643 | *result = *((long double *) t); |
632 | return (ssize_t) length; | 644 | return (ssize_t) length; |
633 | } | 645 | } |
634 | 646 | ||
647 | |||
635 | static const char stream_type_letters[] = "?vat"; /*[0]-no, [1]-video,[2]-audio,[3]-text */ | 648 | static const char stream_type_letters[] = "?vat"; /*[0]-no, [1]-video,[2]-audio,[3]-text */ |
636 | 649 | ||
637 | enum EBMLState | 650 | enum EBMLState |
@@ -791,6 +804,7 @@ clean_ebml_state_ebml (struct ebml_state *state) | |||
791 | state->doctype_read_version = 0; | 804 | state->doctype_read_version = 0; |
792 | } | 805 | } |
793 | 806 | ||
807 | |||
794 | static void | 808 | static void |
795 | clean_ebml_state_matroska_simpletags (struct ebml_state *state) | 809 | clean_ebml_state_matroska_simpletags (struct ebml_state *state) |
796 | { | 810 | { |
@@ -809,7 +823,7 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state) | |||
809 | if (el->string != NULL) | 823 | if (el->string != NULL) |
810 | free (el->string); | 824 | free (el->string); |
811 | free (el); | 825 | free (el); |
812 | if (parent != NULL && parent->child == el) | 826 | if ((parent != NULL) && (parent->child == el)) |
813 | parent->child = next; | 827 | parent->child = next; |
814 | el = next; | 828 | el = next; |
815 | if (next == NULL) | 829 | if (next == NULL) |
@@ -820,8 +834,10 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state) | |||
820 | state->tag_current = NULL; | 834 | state->tag_current = NULL; |
821 | } | 835 | } |
822 | 836 | ||
837 | |||
823 | void | 838 | void |
824 | matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, char *name, char *string) | 839 | matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, |
840 | char *name, char *string) | ||
825 | { | 841 | { |
826 | struct matroska_simpletag *el = malloc (sizeof (struct matroska_simpletag)); | 842 | struct matroska_simpletag *el = malloc (sizeof (struct matroska_simpletag)); |
827 | el->parent = parent; | 843 | el->parent = parent; |
@@ -839,6 +855,7 @@ matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, c | |||
839 | state->tag_last = el; | 855 | state->tag_last = el; |
840 | } | 856 | } |
841 | 857 | ||
858 | |||
842 | static void | 859 | static void |
843 | clean_ebml_state_matroska_seeks (struct ebml_state *state) | 860 | clean_ebml_state_matroska_seeks (struct ebml_state *state) |
844 | { | 861 | { |
@@ -852,6 +869,7 @@ clean_ebml_state_matroska_seeks (struct ebml_state *state) | |||
852 | state->matroska_seeks_tail = NULL; | 869 | state->matroska_seeks_tail = NULL; |
853 | } | 870 | } |
854 | 871 | ||
872 | |||
855 | static void | 873 | static void |
856 | clean_ebml_state_matroska_segment (struct ebml_state *state) | 874 | clean_ebml_state_matroska_segment (struct ebml_state *state) |
857 | { | 875 | { |
@@ -862,6 +880,7 @@ clean_ebml_state_matroska_segment (struct ebml_state *state) | |||
862 | clean_ebml_state_matroska_simpletags (state); | 880 | clean_ebml_state_matroska_simpletags (state); |
863 | } | 881 | } |
864 | 882 | ||
883 | |||
865 | static void | 884 | static void |
866 | clean_ebml_state_matroska_seek (struct ebml_state *state) | 885 | clean_ebml_state_matroska_seek (struct ebml_state *state) |
867 | { | 886 | { |
@@ -869,6 +888,7 @@ clean_ebml_state_matroska_seek (struct ebml_state *state) | |||
869 | state->matroska_seek_position = 0; | 888 | state->matroska_seek_position = 0; |
870 | } | 889 | } |
871 | 890 | ||
891 | |||
872 | static void | 892 | static void |
873 | clean_ebml_state_matroska_info (struct ebml_state *state) | 893 | clean_ebml_state_matroska_info (struct ebml_state *state) |
874 | { | 894 | { |
@@ -889,6 +909,7 @@ clean_ebml_state_matroska_info (struct ebml_state *state) | |||
889 | state->matroska_info_writing_app = NULL; | 909 | state->matroska_info_writing_app = NULL; |
890 | } | 910 | } |
891 | 911 | ||
912 | |||
892 | static void | 913 | static void |
893 | clean_ebml_state_matroska_track_video (struct ebml_state *state) | 914 | clean_ebml_state_matroska_track_video (struct ebml_state *state) |
894 | { | 915 | { |
@@ -902,6 +923,7 @@ clean_ebml_state_matroska_track_video (struct ebml_state *state) | |||
902 | state->matroska_track_video_display_unit = 0; | 923 | state->matroska_track_video_display_unit = 0; |
903 | } | 924 | } |
904 | 925 | ||
926 | |||
905 | static void | 927 | static void |
906 | clean_ebml_state_matroska_track_audio (struct ebml_state *state) | 928 | clean_ebml_state_matroska_track_audio (struct ebml_state *state) |
907 | { | 929 | { |
@@ -912,6 +934,7 @@ clean_ebml_state_matroska_track_audio (struct ebml_state *state) | |||
912 | state->matroska_track_audio_bit_depth = 0; | 934 | state->matroska_track_audio_bit_depth = 0; |
913 | } | 935 | } |
914 | 936 | ||
937 | |||
915 | static void | 938 | static void |
916 | clean_ebml_state_matroska_track (struct ebml_state *state) | 939 | clean_ebml_state_matroska_track (struct ebml_state *state) |
917 | { | 940 | { |
@@ -935,6 +958,7 @@ clean_ebml_state_matroska_track (struct ebml_state *state) | |||
935 | clean_ebml_state_matroska_track_audio (state); | 958 | clean_ebml_state_matroska_track_audio (state); |
936 | } | 959 | } |
937 | 960 | ||
961 | |||
938 | static struct ebml_state * | 962 | static struct ebml_state * |
939 | EXTRACTOR_ebml_init_state_method () | 963 | EXTRACTOR_ebml_init_state_method () |
940 | { | 964 | { |
@@ -952,14 +976,17 @@ EXTRACTOR_ebml_init_state_method () | |||
952 | return state; | 976 | return state; |
953 | } | 977 | } |
954 | 978 | ||
979 | |||
955 | static void | 980 | static void |
956 | report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 981 | report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, |
982 | void *proc_cls) | ||
957 | { | 983 | { |
958 | struct matroska_simpletag *el, *next; | 984 | struct matroska_simpletag *el, *next; |
959 | char format[MAX_STRING_SIZE + 1]; | 985 | char format[MAX_STRING_SIZE + 1]; |
960 | for (el = state->tag_tree; el != NULL; el = next) | 986 | for (el = state->tag_tree; el != NULL; el = next) |
961 | { | 987 | { |
962 | if (el->name != NULL && el->name[0] != '\0' && el->string != NULL && el->string[0] != '\0') | 988 | if ((el->name != NULL) && (el->name[0] != '\0') && (el->string != NULL) && |
989 | (el->string[0] != '\0') ) | ||
963 | { | 990 | { |
964 | enum EXTRACTOR_MetaType metatype = EXTRACTOR_METATYPE_RESERVED; | 991 | enum EXTRACTOR_MetaType metatype = EXTRACTOR_METATYPE_RESERVED; |
965 | struct MatroskaTagMap *map_item; | 992 | struct MatroskaTagMap *map_item; |
@@ -975,10 +1002,10 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo | |||
975 | { | 1002 | { |
976 | snprintf (format, MAX_STRING_SIZE, "%s=%s", el->name, el->string); | 1003 | snprintf (format, MAX_STRING_SIZE, "%s=%s", el->name, el->string); |
977 | format[MAX_STRING_SIZE] = '\0'; | 1004 | format[MAX_STRING_SIZE] = '\0'; |
978 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_UNKNOWN); | 1005 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_UNKNOWN); |
979 | } | 1006 | } |
980 | else | 1007 | else |
981 | ADD_MATROSKA(el->string, metatype); | 1008 | ADD_MATROSKA (el->string, metatype); |
982 | } | 1009 | } |
983 | next = el->child; | 1010 | next = el->child; |
984 | while (next == NULL && el != NULL) | 1011 | while (next == NULL && el != NULL) |
@@ -991,18 +1018,21 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo | |||
991 | clean_ebml_state_matroska_simpletags (state); | 1018 | clean_ebml_state_matroska_simpletags (state); |
992 | } | 1019 | } |
993 | 1020 | ||
1021 | |||
994 | static void | 1022 | static void |
995 | report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 1023 | report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, |
1024 | void *proc_cls) | ||
996 | { | 1025 | { |
997 | char format[MAX_STRING_SIZE + 1]; | 1026 | char format[MAX_STRING_SIZE + 1]; |
998 | report_simpletag (state, proc, proc_cls); | 1027 | report_simpletag (state, proc, proc_cls); |
999 | if (state->valid_ebml && !state->reported_ebml) | 1028 | if (state->valid_ebml && ! state->reported_ebml) |
1000 | { | 1029 | { |
1001 | state->reported_ebml = 1; | 1030 | state->reported_ebml = 1; |
1002 | snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long long) state->ebml_version); | 1031 | snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long |
1032 | long) state->ebml_version); | ||
1003 | format[MAX_STRING_SIZE] = '\0'; | 1033 | format[MAX_STRING_SIZE] = '\0'; |
1004 | ADD_EBML(format, EXTRACTOR_METATYPE_FORMAT_VERSION); | 1034 | ADD_EBML (format, EXTRACTOR_METATYPE_FORMAT_VERSION); |
1005 | snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype, | 1035 | snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype, |
1006 | (unsigned long long) state->doctype_version, | 1036 | (unsigned long long) state->doctype_version, |
1007 | (unsigned long long) state->ebml_version); | 1037 | (unsigned long long) state->ebml_version); |
1008 | format[MAX_STRING_SIZE] = '\0'; | 1038 | format[MAX_STRING_SIZE] = '\0'; |
@@ -1012,21 +1042,25 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1012 | clean_ebml_state_ebml (state); | 1042 | clean_ebml_state_ebml (state); |
1013 | if (state->valid_matroska_info == -1) | 1043 | if (state->valid_matroska_info == -1) |
1014 | { | 1044 | { |
1015 | if ((state->matroska_info_duration > 0 || state->matroska_info_duration == -1.0) && | 1045 | if (((state->matroska_info_duration > 0) || |
1016 | state->matroska_info_muxing_app != NULL && state->matroska_info_writing_app != NULL) | 1046 | (state->matroska_info_duration == -1.0) ) && |
1047 | (state->matroska_info_muxing_app != NULL) && | ||
1048 | (state->matroska_info_writing_app != NULL) ) | ||
1017 | state->valid_matroska_info = 1; | 1049 | state->valid_matroska_info = 1; |
1018 | else | 1050 | else |
1019 | state->valid_matroska_info = 0; | 1051 | state->valid_matroska_info = 0; |
1020 | } | 1052 | } |
1021 | if (state->valid_matroska_info == 1 && !state->reported_matroska_info) | 1053 | if ((state->valid_matroska_info == 1) && ! state->reported_matroska_info) |
1022 | { | 1054 | { |
1023 | state->reported_matroska_info = 1; | 1055 | state->reported_matroska_info = 1; |
1024 | if (state->matroska_info_duration != -1.0) | 1056 | if (state->matroska_info_duration != -1.0) |
1025 | { | 1057 | { |
1026 | uint64_t seconds = (uint64_t) ((state->matroska_info_duration * (float) state->matroska_info_timecode_scale) / 1e+9); | 1058 | uint64_t seconds = (uint64_t) ((state->matroska_info_duration |
1059 | * (float) state-> | ||
1060 | matroska_info_timecode_scale) / 1e+9); | ||
1027 | snprintf (format, MAX_STRING_SIZE, "%llus", (unsigned long long) seconds); | 1061 | snprintf (format, MAX_STRING_SIZE, "%llus", (unsigned long long) seconds); |
1028 | format[MAX_STRING_SIZE] = '\0'; | 1062 | format[MAX_STRING_SIZE] = '\0'; |
1029 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_DURATION); | 1063 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_DURATION); |
1030 | } | 1064 | } |
1031 | if (state->matroska_info_date_utc_is_set) | 1065 | if (state->matroska_info_date_utc_is_set) |
1032 | { | 1066 | { |
@@ -1052,8 +1086,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1052 | * millenium is known and never changes), but we want to use 64-bit integer to | 1086 | * millenium is known and never changes), but we want to use 64-bit integer to |
1053 | * manipulate time. If it gets trimmed later, when assigning back to a TIME_TYPE | 1087 | * manipulate time. If it gets trimmed later, when assigning back to a TIME_TYPE |
1054 | * that happens to be 32-bit long - well, tough luck. | 1088 | * that happens to be 32-bit long - well, tough luck. |
1055 | */ | 1089 | */errno = 0; |
1056 | errno = 0; | ||
1057 | #if WINDOWS | 1090 | #if WINDOWS |
1058 | millenium_start_stamp = _mktime64 (&millenium_start); | 1091 | millenium_start_stamp = _mktime64 (&millenium_start); |
1059 | #else | 1092 | #else |
@@ -1061,58 +1094,69 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1061 | #endif | 1094 | #endif |
1062 | if (millenium_start_stamp == -1) | 1095 | if (millenium_start_stamp == -1) |
1063 | printf ("Failed to convert time: %d\n", errno); | 1096 | printf ("Failed to convert time: %d\n", errno); |
1064 | matroska_date_stamp = millenium_start_stamp * 1000000000 + state->matroska_info_date_utc; | 1097 | matroska_date_stamp = millenium_start_stamp * 1000000000 |
1098 | + state->matroska_info_date_utc; | ||
1065 | /* Now matroska_date_stamp is the number of nanoseconds since UNIX Epoch */ | 1099 | /* Now matroska_date_stamp is the number of nanoseconds since UNIX Epoch */ |
1066 | matroska_date_stamp_time_t = matroska_date_stamp / 1000000000; | 1100 | matroska_date_stamp_time_t = matroska_date_stamp / 1000000000; |
1067 | /* Now matroska_date_stamp_time_t is the number of seconds since UNIX Epoch */ | 1101 | /* Now matroska_date_stamp_time_t is the number of seconds since UNIX Epoch */ |
1068 | #if WINDOWS | 1102 | #if WINDOWS |
1069 | if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t, &matroska_date)) | 1103 | if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t, |
1104 | &matroska_date)) | ||
1070 | #else | 1105 | #else |
1071 | /* We want to be thread-safe. If you have no gmtime_r(), think of something! */ | 1106 | /* We want to be thread-safe. If you have no gmtime_r(), think of something! */ |
1072 | if (NULL != gmtime_r (&matroska_date_stamp_time_t, &matroska_date)) | 1107 | if (NULL != gmtime_r (&matroska_date_stamp_time_t, &matroska_date)) |
1073 | #endif | 1108 | #endif |
1074 | { | 1109 | { |
1075 | if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC", &matroska_date)) | 1110 | if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC", |
1076 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATION_DATE); | 1111 | &matroska_date)) |
1112 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATION_DATE); | ||
1077 | } | 1113 | } |
1078 | } | 1114 | } |
1079 | if (state->matroska_info_title != NULL) | 1115 | if (state->matroska_info_title != NULL) |
1080 | ADD_MATROSKA(state->matroska_info_title, EXTRACTOR_METATYPE_TITLE); | 1116 | ADD_MATROSKA (state->matroska_info_title, EXTRACTOR_METATYPE_TITLE); |
1081 | if (strcmp (state->matroska_info_writing_app, state->matroska_info_muxing_app) == 0) | 1117 | if (strcmp (state->matroska_info_writing_app, |
1082 | snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s", state->matroska_info_writing_app); | 1118 | state->matroska_info_muxing_app) == 0) |
1119 | snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s", | ||
1120 | state->matroska_info_writing_app); | ||
1083 | else | 1121 | else |
1084 | snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s", state->matroska_info_writing_app, state->matroska_info_muxing_app); | 1122 | snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s", |
1123 | state->matroska_info_writing_app, | ||
1124 | state->matroska_info_muxing_app); | ||
1085 | format[MAX_STRING_SIZE] = '\0'; | 1125 | format[MAX_STRING_SIZE] = '\0'; |
1086 | ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); | 1126 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE); |
1087 | } | 1127 | } |
1088 | if (state->valid_matroska_info == 1) | 1128 | if (state->valid_matroska_info == 1) |
1089 | clean_ebml_state_matroska_info (state); | 1129 | clean_ebml_state_matroska_info (state); |
1090 | if (state->valid_matroska_track == -1) | 1130 | if (state->valid_matroska_track == -1) |
1091 | { | 1131 | { |
1092 | if ((state->matroska_track_type > 0 && state->matroska_track_type < 255) && | 1132 | if (((state->matroska_track_type > 0) && (state->matroska_track_type < |
1093 | state->matroska_track_codec_id != NULL) | 1133 | 255) ) && |
1134 | (state->matroska_track_codec_id != NULL) ) | ||
1094 | state->valid_matroska_track = 1; | 1135 | state->valid_matroska_track = 1; |
1095 | else | 1136 | else |
1096 | state->valid_matroska_track = 0; | 1137 | state->valid_matroska_track = 0; |
1097 | } | 1138 | } |
1098 | if (state->valid_matroska_track_video == -1) | 1139 | if (state->valid_matroska_track_video == -1) |
1099 | { | 1140 | { |
1100 | if ((state->matroska_track_video_flag_interlaced == 0 || state->matroska_track_video_flag_interlaced == 1) && | 1141 | if (((state->matroska_track_video_flag_interlaced == 0) || |
1101 | (state->matroska_track_video_stereo_mode >= 0 && state->matroska_track_video_stereo_mode <= 14) && | 1142 | (state->matroska_track_video_flag_interlaced == 1) ) && |
1102 | state->matroska_track_video_pixel_width > 0 && state->matroska_track_video_pixel_height > 0) | 1143 | ((state->matroska_track_video_stereo_mode >= 0) && |
1144 | (state->matroska_track_video_stereo_mode <= 14) ) && | ||
1145 | (state->matroska_track_video_pixel_width > 0) && | ||
1146 | (state->matroska_track_video_pixel_height > 0) ) | ||
1103 | state->valid_matroska_track_video = 1; | 1147 | state->valid_matroska_track_video = 1; |
1104 | else | 1148 | else |
1105 | state->valid_matroska_track_video = 0; | 1149 | state->valid_matroska_track_video = 0; |
1106 | } | 1150 | } |
1107 | if (state->valid_matroska_track_audio == -1) | 1151 | if (state->valid_matroska_track_audio == -1) |
1108 | { | 1152 | { |
1109 | if (state->matroska_track_audio_sampling_frequency > 0 && | 1153 | if ((state->matroska_track_audio_sampling_frequency > 0) && |
1110 | state->matroska_track_audio_channels > 0) | 1154 | (state->matroska_track_audio_channels > 0) ) |
1111 | state->valid_matroska_track_audio = 1; | 1155 | state->valid_matroska_track_audio = 1; |
1112 | else | 1156 | else |
1113 | state->valid_matroska_track_audio = 0; | 1157 | state->valid_matroska_track_audio = 0; |
1114 | } | 1158 | } |
1115 | if (state->valid_matroska_track == 1 && !state->reported_matroska_track) | 1159 | if ((state->valid_matroska_track == 1) && ! state->reported_matroska_track) |
1116 | { | 1160 | { |
1117 | char name_part[MAX_STRING_SIZE + 1]; | 1161 | char name_part[MAX_STRING_SIZE + 1]; |
1118 | char codec_part[MAX_STRING_SIZE + 1]; | 1162 | char codec_part[MAX_STRING_SIZE + 1]; |
@@ -1142,28 +1186,32 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1142 | if (state->matroska_track_name == NULL) | 1186 | if (state->matroska_track_name == NULL) |
1143 | snprintf (name_part, MAX_STRING_SIZE, "%s", ""); | 1187 | snprintf (name_part, MAX_STRING_SIZE, "%s", ""); |
1144 | else | 1188 | else |
1145 | snprintf (name_part, MAX_STRING_SIZE, "`%s' ", state->matroska_track_name); | 1189 | snprintf (name_part, MAX_STRING_SIZE, "`%s' ", |
1190 | state->matroska_track_name); | ||
1146 | name_part[MAX_STRING_SIZE] = '\0'; | 1191 | name_part[MAX_STRING_SIZE] = '\0'; |
1147 | 1192 | ||
1148 | if (state->matroska_track_codec_name == NULL) | 1193 | if (state->matroska_track_codec_name == NULL) |
1149 | snprintf (codec_part, MAX_STRING_SIZE, "%s", state->matroska_track_codec_id); | 1194 | snprintf (codec_part, MAX_STRING_SIZE, "%s", |
1195 | state->matroska_track_codec_id); | ||
1150 | else | 1196 | else |
1151 | snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]", state->matroska_track_codec_id, state->matroska_track_codec_name); | 1197 | snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]", |
1198 | state->matroska_track_codec_id, | ||
1199 | state->matroska_track_codec_name); | ||
1152 | codec_part[MAX_STRING_SIZE] = '\0'; | 1200 | codec_part[MAX_STRING_SIZE] = '\0'; |
1153 | 1201 | ||
1154 | if (use_video && state->valid_matroska_track_video == 1) | 1202 | if (use_video && (state->valid_matroska_track_video == 1)) |
1155 | { | 1203 | { |
1156 | /* Ignore Display* for now. Aspect ratio correction could be | 1204 | /* Ignore Display* for now. Aspect ratio correction could be |
1157 | * done either way (stretching horizontally or squishing vertically), | 1205 | * done either way (stretching horizontally or squishing vertically), |
1158 | * so let's stick to hard cold pixel counts. | 1206 | * so let's stick to hard cold pixel counts. |
1159 | */ | 1207 | */ |
1160 | snprintf (format, MAX_STRING_SIZE, "%llux%llu", | 1208 | snprintf (format, MAX_STRING_SIZE, "%llux%llu", |
1161 | (unsigned long long) state->matroska_track_video_pixel_width, | 1209 | (unsigned long long) state->matroska_track_video_pixel_width, |
1162 | (unsigned long long) state->matroska_track_video_pixel_height); | 1210 | (unsigned long long) state->matroska_track_video_pixel_height); |
1163 | format[MAX_STRING_SIZE] = '\0'; | 1211 | format[MAX_STRING_SIZE] = '\0'; |
1164 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); | 1212 | ADD_MATROSKA (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS); |
1165 | } | 1213 | } |
1166 | if (use_audio && state->valid_matroska_track_audio == 1) | 1214 | if (use_audio && (state->valid_matroska_track_audio == 1)) |
1167 | { | 1215 | { |
1168 | double freq = state->matroska_track_audio_sampling_frequency; | 1216 | double freq = state->matroska_track_audio_sampling_frequency; |
1169 | double rfreq = freq; | 1217 | double rfreq = freq; |
@@ -1176,20 +1224,24 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1176 | hz_part[MAX_STRING_SIZE] = '\0'; | 1224 | hz_part[MAX_STRING_SIZE] = '\0'; |
1177 | 1225 | ||
1178 | if (state->matroska_track_audio_bit_depth > 0) | 1226 | if (state->matroska_track_audio_bit_depth > 0) |
1179 | snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long long) state->matroska_track_audio_bit_depth); | 1227 | snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long |
1228 | long) state-> | ||
1229 | matroska_track_audio_bit_depth); | ||
1180 | else | 1230 | else |
1181 | bit_part[0] = '\0'; | 1231 | bit_part[0] = '\0'; |
1182 | bit_part[MAX_STRING_SIZE] = '\0'; | 1232 | bit_part[MAX_STRING_SIZE] = '\0'; |
1183 | 1233 | ||
1184 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s, %llu-channel %sat %s) [%s]", | 1234 | snprintf (format, MAX_STRING_SIZE, |
1185 | track_type_string, name_part, codec_part, | 1235 | "%s track %s(%s, %llu-channel %sat %s) [%s]", |
1186 | (unsigned long long) state->matroska_track_audio_channels, | 1236 | track_type_string, name_part, codec_part, |
1187 | bit_part, hz_part, state->matroska_track_language); | 1237 | (unsigned long long) state->matroska_track_audio_channels, |
1238 | bit_part, hz_part, state->matroska_track_language); | ||
1188 | } | 1239 | } |
1189 | else | 1240 | else |
1190 | { | 1241 | { |
1191 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s) [%s]", | 1242 | snprintf (format, MAX_STRING_SIZE, "%s track %s(%s) [%s]", |
1192 | track_type_string, name_part, codec_part, state->matroska_track_language); | 1243 | track_type_string, name_part, codec_part, |
1244 | state->matroska_track_language); | ||
1193 | } | 1245 | } |
1194 | format[MAX_STRING_SIZE] = '\0'; | 1246 | format[MAX_STRING_SIZE] = '\0'; |
1195 | ADD_EBML (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); | 1247 | ADD_EBML (format, EXTRACTOR_METATYPE_RESOURCE_TYPE); |
@@ -1199,7 +1251,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void * | |||
1199 | } | 1251 | } |
1200 | 1252 | ||
1201 | 1253 | ||
1202 | static int | 1254 | static int |
1203 | EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) | 1255 | EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) |
1204 | { | 1256 | { |
1205 | if (state != NULL) | 1257 | if (state != NULL) |
@@ -1214,6 +1266,7 @@ EXTRACTOR_ebml_discard_state_method (struct ebml_state *state) | |||
1214 | return 1; | 1266 | return 1; |
1215 | } | 1267 | } |
1216 | 1268 | ||
1269 | |||
1217 | static struct ebml_element * | 1270 | static struct ebml_element * |
1218 | ebml_stack_pop (struct ebml_state *state) | 1271 | ebml_stack_pop (struct ebml_state *state) |
1219 | { | 1272 | { |
@@ -1227,7 +1280,10 @@ ebml_stack_pop (struct ebml_state *state) | |||
1227 | 1280 | ||
1228 | 1281 | ||
1229 | static void | 1282 | static void |
1230 | ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, uint64_t size, uint64_t header_size, int finish_state, int prev_state, int bail_state, int bail_next_state) | 1283 | ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, |
1284 | uint64_t size, uint64_t header_size, int finish_state, int | ||
1285 | prev_state, int | ||
1286 | bail_state, int bail_next_state) | ||
1231 | { | 1287 | { |
1232 | struct ebml_element *element = malloc (sizeof (struct ebml_element)); | 1288 | struct ebml_element *element = malloc (sizeof (struct ebml_element)); |
1233 | element->parent = state->stack_top; | 1289 | element->parent = state->stack_top; |
@@ -1242,8 +1298,10 @@ ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, u | |||
1242 | element->bail_next_state = bail_next_state; | 1298 | element->bail_next_state = bail_next_state; |
1243 | } | 1299 | } |
1244 | 1300 | ||
1301 | |||
1245 | static int | 1302 | static int |
1246 | check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct ebml_state *state) | 1303 | check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct |
1304 | ebml_state *state) | ||
1247 | { | 1305 | { |
1248 | if (read_result == 0) | 1306 | if (read_result == 0) |
1249 | { | 1307 | { |
@@ -1256,7 +1314,7 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e | |||
1256 | return 0; | 1314 | return 0; |
1257 | } | 1315 | } |
1258 | offset = parent->position + parent->header_size + parent->size; | 1316 | offset = parent->position + parent->header_size + parent->size; |
1259 | if (offset < 0 || offset != pl_seek (plugin, offset, SEEK_SET)) | 1317 | if ((offset < 0) || (offset != pl_seek (plugin, offset, SEEK_SET))) |
1260 | { | 1318 | { |
1261 | state->state = EBML_BAD_STATE; | 1319 | state->state = EBML_BAD_STATE; |
1262 | return 0; | 1320 | return 0; |
@@ -1269,12 +1327,16 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e | |||
1269 | return 1; | 1327 | return 1; |
1270 | } | 1328 | } |
1271 | 1329 | ||
1330 | |||
1272 | static int | 1331 | static int |
1273 | maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int *do_break, int64_t read_result) | 1332 | maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, |
1333 | int *do_break, int64_t read_result) | ||
1274 | { | 1334 | { |
1275 | int64_t offset; | 1335 | int64_t offset; |
1276 | offset = pl_get_pos (plugin) - read_result; | 1336 | offset = pl_get_pos (plugin) - read_result; |
1277 | if (state->stack_top != NULL && offset >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 1337 | if ((state->stack_top != NULL) && (offset >= state->stack_top->position |
1338 | + state->stack_top->header_size | ||
1339 | + state->stack_top->size) ) | ||
1278 | { | 1340 | { |
1279 | state->state = state->stack_top->finish_state; | 1341 | state->state = state->stack_top->finish_state; |
1280 | pl_seek (plugin, -read_result, SEEK_CUR); | 1342 | pl_seek (plugin, -read_result, SEEK_CUR); |
@@ -1284,24 +1346,29 @@ maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, in | |||
1284 | return 0; | 1346 | return 0; |
1285 | } | 1347 | } |
1286 | 1348 | ||
1349 | |||
1287 | static void | 1350 | static void |
1288 | rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int next_state) | 1351 | rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct |
1352 | ebml_state *state, int next_state) | ||
1289 | { | 1353 | { |
1290 | int64_t offset; | 1354 | int64_t offset; |
1291 | state->state = EBML_READ_ELEMENT; | 1355 | state->state = EBML_READ_ELEMENT; |
1292 | offset = state->stack_top->position + state->stack_top->header_size + state->stack_top->size; | 1356 | offset = state->stack_top->position + state->stack_top->header_size |
1357 | + state->stack_top->size; | ||
1293 | free (ebml_stack_pop (state)); | 1358 | free (ebml_stack_pop (state)); |
1294 | state->next_state = next_state; | 1359 | state->next_state = next_state; |
1295 | pl_seek (plugin, offset, SEEK_SET); | 1360 | pl_seek (plugin, offset, SEEK_SET); |
1296 | } | 1361 | } |
1297 | 1362 | ||
1363 | |||
1298 | static void | 1364 | static void |
1299 | try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | 1365 | try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) |
1300 | { | 1366 | { |
1301 | if (state->matroska_seeks != NULL) | 1367 | if (state->matroska_seeks != NULL) |
1302 | { | 1368 | { |
1303 | struct matroska_seek_list *el, *pos = NULL; | 1369 | struct matroska_seek_list *el, *pos = NULL; |
1304 | int64_t segment_position = pl_get_pos (plugin) - state->segment_contents_start; | 1370 | int64_t segment_position = pl_get_pos (plugin) |
1371 | - state->segment_contents_start; | ||
1305 | for (el = state->matroska_seeks; el != NULL; el = el->next) | 1372 | for (el = state->matroska_seeks; el != NULL; el = el->next) |
1306 | { | 1373 | { |
1307 | if (el->position <= segment_position) | 1374 | if (el->position <= segment_position) |
@@ -1314,8 +1381,10 @@ try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | |||
1314 | } | 1381 | } |
1315 | } | 1382 | } |
1316 | 1383 | ||
1384 | |||
1317 | static void | 1385 | static void |
1318 | maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state) | 1386 | maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct |
1387 | ebml_state *state) | ||
1319 | { | 1388 | { |
1320 | int64_t offset; | 1389 | int64_t offset; |
1321 | struct matroska_seek_list *el; | 1390 | struct matroska_seek_list *el; |
@@ -1350,12 +1419,14 @@ maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct | |||
1350 | * the one we've got from seek table. If it doesn't match - stop parsing the file. | 1419 | * the one we've got from seek table. If it doesn't match - stop parsing the file. |
1351 | */ | 1420 | */ |
1352 | #if DEBUG_EBML | 1421 | #if DEBUG_EBML |
1353 | printf ("Seeking from %llu to %llu\n", offset, el->position + state->segment_contents_start); | 1422 | printf ("Seeking from %llu to %llu\n", offset, el->position |
1423 | + state->segment_contents_start); | ||
1354 | #endif | 1424 | #endif |
1355 | pl_seek (plugin, el->position + state->segment_contents_start, SEEK_SET); | 1425 | pl_seek (plugin, el->position + state->segment_contents_start, SEEK_SET); |
1356 | } | 1426 | } |
1357 | } | 1427 | } |
1358 | 1428 | ||
1429 | |||
1359 | static void | 1430 | static void |
1360 | sort_seeks (struct ebml_state *state) | 1431 | sort_seeks (struct ebml_state *state) |
1361 | { | 1432 | { |
@@ -1363,7 +1434,7 @@ sort_seeks (struct ebml_state *state) | |||
1363 | int64_t position; | 1434 | int64_t position; |
1364 | struct matroska_seek_list *el; | 1435 | struct matroska_seek_list *el; |
1365 | char sorted = 0; | 1436 | char sorted = 0; |
1366 | while (!sorted) | 1437 | while (! sorted) |
1367 | { | 1438 | { |
1368 | sorted = 1; | 1439 | sorted = 1; |
1369 | for (el = state->matroska_seeks; el != NULL; el = el->next) | 1440 | for (el = state->matroska_seeks; el != NULL; el = el->next) |
@@ -1386,7 +1457,8 @@ sort_seeks (struct ebml_state *state) | |||
1386 | 1457 | ||
1387 | 1458 | ||
1388 | int | 1459 | int |
1389 | EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | 1460 | EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, |
1461 | EXTRACTOR_MetaDataProcessor proc, void *proc_cls) | ||
1390 | { | 1462 | { |
1391 | uint64_t offset = 0; | 1463 | uint64_t offset = 0; |
1392 | ssize_t read_result; | 1464 | ssize_t read_result; |
@@ -1406,7 +1478,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1406 | 1478 | ||
1407 | if (plugin == NULL) | 1479 | if (plugin == NULL) |
1408 | return 1; | 1480 | return 1; |
1409 | 1481 | ||
1410 | state = EXTRACTOR_ebml_init_state_method (); | 1482 | state = EXTRACTOR_ebml_init_state_method (); |
1411 | if (state == NULL) | 1483 | if (state == NULL) |
1412 | return 1; | 1484 | return 1; |
@@ -1421,7 +1493,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1421 | return EXTRACTOR_ebml_discard_state_method (state); | 1493 | return EXTRACTOR_ebml_discard_state_method (state); |
1422 | case EBML_LOOKING_FOR_HEADER: | 1494 | case EBML_LOOKING_FOR_HEADER: |
1423 | offset = pl_get_pos (plugin); | 1495 | offset = pl_get_pos (plugin); |
1424 | sint_value = pl_read (plugin, &data, 1024*1024); | 1496 | sint_value = pl_read (plugin, &data, 1024 * 1024); |
1425 | if (sint_value < 4) | 1497 | if (sint_value < 4) |
1426 | return EXTRACTOR_ebml_discard_state_method (state); | 1498 | return EXTRACTOR_ebml_discard_state_method (state); |
1427 | start = NULL; | 1499 | start = NULL; |
@@ -1433,12 +1505,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1433 | offset = pl_get_pos (plugin) - 3; | 1505 | offset = pl_get_pos (plugin) - 3; |
1434 | if (offset != pl_seek (plugin, offset, SEEK_SET)) | 1506 | if (offset != pl_seek (plugin, offset, SEEK_SET)) |
1435 | return EXTRACTOR_ebml_discard_state_method (state); | 1507 | return EXTRACTOR_ebml_discard_state_method (state); |
1436 | sint_value = pl_read (plugin, &data, 1024*1024); | 1508 | sint_value = pl_read (plugin, &data, 1024 * 1024); |
1437 | if (sint_value < 4) | 1509 | if (sint_value < 4) |
1438 | return EXTRACTOR_ebml_discard_state_method (state); | 1510 | return EXTRACTOR_ebml_discard_state_method (state); |
1439 | } | 1511 | } |
1440 | } | 1512 | } |
1441 | if (offset + start - data != pl_seek (plugin, offset + start - data, SEEK_SET)) | 1513 | if (offset + start - data != pl_seek (plugin, offset + start - data, |
1514 | SEEK_SET)) | ||
1442 | return EXTRACTOR_ebml_discard_state_method (state); | 1515 | return EXTRACTOR_ebml_discard_state_method (state); |
1443 | state->state = EBML_READING_HEADER; | 1516 | state->state = EBML_READING_HEADER; |
1444 | break; | 1517 | break; |
@@ -1458,7 +1531,9 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1458 | } | 1531 | } |
1459 | state->state = EBML_READ_ELEMENT; | 1532 | state->state = EBML_READ_ELEMENT; |
1460 | state->next_state = EBML_READING_HEADER_ELEMENTS; | 1533 | state->next_state = EBML_READING_HEADER_ELEMENTS; |
1461 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE); | 1534 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1535 | EBML_FINISHED_READING_HEADER, EBML_BAD_STATE, | ||
1536 | EBML_FINISHED_READING_HEADER, EBML_BAD_STATE); | ||
1462 | break; | 1537 | break; |
1463 | case EBML_READ_ELEMENT: | 1538 | case EBML_READ_ELEMENT: |
1464 | #if DEBUG_EBML | 1539 | #if DEBUG_EBML |
@@ -1475,19 +1550,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1475 | } | 1550 | } |
1476 | state->state = state->next_state; | 1551 | state->state = state->next_state; |
1477 | break; | 1552 | break; |
1478 | */ | 1553 | *//* while the following code crashes with SIGILL. |
1479 | /* while the following code crashes with SIGILL. | 1554 | *//* |
1480 | */ | ||
1481 | /* | ||
1482 | read_result = elementRead (plugin, &eID, &eSize); | 1555 | read_result = elementRead (plugin, &eID, &eSize); |
1483 | state->state = state->next_state; | 1556 | state->state = state->next_state; |
1484 | if (read_result < 0) | 1557 | if (read_result < 0) |
1485 | state->state = EBML_BAD_STATE; | 1558 | state->state = EBML_BAD_STATE; |
1486 | break; | 1559 | break; |
1487 | */ | 1560 | *//* but the following code works as intended *//* All three code snippets were compiled with -O0 */{ |
1488 | /* but the following code works as intended */ | ||
1489 | /* All three code snippets were compiled with -O0 */ | ||
1490 | { | ||
1491 | enum EBMLState next_state = state->next_state; | 1561 | enum EBMLState next_state = state->next_state; |
1492 | state->state = EBML_BAD_STATE; | 1562 | state->state = EBML_BAD_STATE; |
1493 | read_result = elementRead (plugin, &eID, (int64_t*) &eSize); | 1563 | read_result = elementRead (plugin, &eID, (int64_t*) &eSize); |
@@ -1506,7 +1576,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1506 | read_result = 0; | 1576 | read_result = 0; |
1507 | else | 1577 | else |
1508 | { | 1578 | { |
1509 | if (0 > (read_result = uintRead (plugin, state->stack_top->size, &uint_value))) | 1579 | if (0 > (read_result = uintRead (plugin, state->stack_top->size, |
1580 | &uint_value))) | ||
1510 | { | 1581 | { |
1511 | state->state = EBML_BAD_STATE; | 1582 | state->state = EBML_BAD_STATE; |
1512 | break; | 1583 | break; |
@@ -1516,7 +1587,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1516 | state->state = state->next_state; | 1587 | state->state = state->next_state; |
1517 | break; | 1588 | break; |
1518 | case EBML_READ_ID: | 1589 | case EBML_READ_ID: |
1519 | if (0 > (read_result = idRead (plugin, state->stack_top->size, &id_value))) | 1590 | if (0 > (read_result = idRead (plugin, state->stack_top->size, |
1591 | &id_value))) | ||
1520 | { | 1592 | { |
1521 | state->state = EBML_BAD_STATE; | 1593 | state->state = EBML_BAD_STATE; |
1522 | break; | 1594 | break; |
@@ -1534,7 +1606,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1534 | read_result = 0; | 1606 | read_result = 0; |
1535 | else | 1607 | else |
1536 | { | 1608 | { |
1537 | if (0 > (read_result = sintRead (plugin, state->stack_top->size, &sint_value))) | 1609 | if (0 > (read_result = sintRead (plugin, state->stack_top->size, |
1610 | &sint_value))) | ||
1538 | { | 1611 | { |
1539 | state->state = EBML_BAD_STATE; | 1612 | state->state = EBML_BAD_STATE; |
1540 | break; | 1613 | break; |
@@ -1554,7 +1627,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1554 | read_result = 0; | 1627 | read_result = 0; |
1555 | else | 1628 | else |
1556 | { | 1629 | { |
1557 | if (0 > (read_result = floatRead (plugin, state->stack_top->size, &float_value))) | 1630 | if (0 > (read_result = floatRead (plugin, state->stack_top->size, |
1631 | &float_value))) | ||
1558 | { | 1632 | { |
1559 | state->state = EBML_BAD_STATE; | 1633 | state->state = EBML_BAD_STATE; |
1560 | break; | 1634 | break; |
@@ -1571,7 +1645,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1571 | } | 1645 | } |
1572 | else | 1646 | else |
1573 | { | 1647 | { |
1574 | if (0 > (read_result = stringRead (plugin, state->stack_top->size, (char *) &string_value))) | 1648 | if (0 > (read_result = stringRead (plugin, state->stack_top->size, |
1649 | (char *) &string_value))) | ||
1575 | { | 1650 | { |
1576 | state->state = EBML_BAD_STATE; | 1651 | state->state = EBML_BAD_STATE; |
1577 | break; | 1652 | break; |
@@ -1581,7 +1656,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1581 | state->state = state->next_state; | 1656 | state->state = state->next_state; |
1582 | break; | 1657 | break; |
1583 | case EBML_READING_HEADER_ELEMENTS: | 1658 | case EBML_READING_HEADER_ELEMENTS: |
1584 | if (!check_result (plugin, read_result, state)) | 1659 | if (! check_result (plugin, read_result, state)) |
1585 | break; | 1660 | break; |
1586 | do_break = 0; | 1661 | do_break = 0; |
1587 | switch (eID) | 1662 | switch (eID) |
@@ -1609,10 +1684,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1609 | if (do_break) | 1684 | if (do_break) |
1610 | break; | 1685 | break; |
1611 | state->next_state = EBML_READING_HEADER_ELEMENT_VALUE; | 1686 | state->next_state = EBML_READING_HEADER_ELEMENT_VALUE; |
1612 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS, EBML_READ_ELEMENT, EBML_READING_HEADER_ELEMENTS); | 1687 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1688 | EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS, | ||
1689 | EBML_READ_ELEMENT, | ||
1690 | EBML_READING_HEADER_ELEMENTS); | ||
1613 | break; | 1691 | break; |
1614 | case EBML_READING_HEADER_ELEMENT_VALUE: | 1692 | case EBML_READING_HEADER_ELEMENT_VALUE: |
1615 | if (!check_result (plugin, read_result, state)) | 1693 | if (! check_result (plugin, read_result, state)) |
1616 | break; | 1694 | break; |
1617 | 1695 | ||
1618 | switch (state->stack_top->id) | 1696 | switch (state->stack_top->id) |
@@ -1632,8 +1710,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1632 | * We also stop right here and do not assume that somewhere further | 1710 | * We also stop right here and do not assume that somewhere further |
1633 | * in the file there's another EBML header that is, maybe, readable | 1711 | * in the file there's another EBML header that is, maybe, readable |
1634 | * by us. If you think this is worth correcting - patches are welcome. | 1712 | * by us. If you think this is worth correcting - patches are welcome. |
1635 | */ | 1713 | */continue; |
1636 | continue; | ||
1637 | } | 1714 | } |
1638 | break; | 1715 | break; |
1639 | case EBMLID_MAX_ID_LENGTH: | 1716 | case EBMLID_MAX_ID_LENGTH: |
@@ -1658,7 +1735,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1658 | rise_up_after_value (plugin, state, EBML_READING_HEADER_ELEMENTS); | 1735 | rise_up_after_value (plugin, state, EBML_READING_HEADER_ELEMENTS); |
1659 | break; | 1736 | break; |
1660 | case EBML_FINISHED_READING_HEADER: | 1737 | case EBML_FINISHED_READING_HEADER: |
1661 | if (!state->valid_ebml) | 1738 | if (! state->valid_ebml) |
1662 | { | 1739 | { |
1663 | /* Header was invalid (lacking doctype). */ | 1740 | /* Header was invalid (lacking doctype). */ |
1664 | state->next_state = EBML_SKIP_UNTIL_NEXT_HEADER; | 1741 | state->next_state = EBML_SKIP_UNTIL_NEXT_HEADER; |
@@ -1680,8 +1757,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1680 | * metadata from it!), we do not care about these differences | 1757 | * metadata from it!), we do not care about these differences |
1681 | * (which means that this code will happily read webm files that do | 1758 | * (which means that this code will happily read webm files that do |
1682 | * not conform to Webm spec, but conform to Matroska spec). | 1759 | * not conform to Webm spec, but conform to Matroska spec). |
1683 | */ | 1760 | */state->next_state = EBML_READING_MATROSKA_SEGMENT; |
1684 | state->next_state = EBML_READING_MATROSKA_SEGMENT; | ||
1685 | } | 1761 | } |
1686 | else | 1762 | else |
1687 | { | 1763 | { |
@@ -1727,11 +1803,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1727 | state->state = EBML_READ_ELEMENT; | 1803 | state->state = EBML_READ_ELEMENT; |
1728 | state->next_state = EBML_READING_MATROSKA_SEGMENT_CONTENTS; | 1804 | state->next_state = EBML_READING_MATROSKA_SEGMENT_CONTENTS; |
1729 | clean_ebml_state_matroska_segment (state); | 1805 | clean_ebml_state_matroska_segment (state); |
1730 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT); | 1806 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1807 | EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1808 | EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT, | ||
1809 | EBML_READING_MATROSKA_SEGMENT); | ||
1731 | state->segment_contents_start = pl_get_pos (plugin); | 1810 | state->segment_contents_start = pl_get_pos (plugin); |
1732 | break; | 1811 | break; |
1733 | case EBML_READING_MATROSKA_SEGMENT_CONTENTS: | 1812 | case EBML_READING_MATROSKA_SEGMENT_CONTENTS: |
1734 | if (!check_result (plugin, read_result, state)) | 1813 | if (! check_result (plugin, read_result, state)) |
1735 | break; | 1814 | break; |
1736 | 1815 | ||
1737 | state->state = EBML_READ_ELEMENT; | 1816 | state->state = EBML_READ_ELEMENT; |
@@ -1739,20 +1818,40 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1739 | { | 1818 | { |
1740 | case MatroskaID_SeekHead: | 1819 | case MatroskaID_SeekHead: |
1741 | state->next_state = EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS; | 1820 | state->next_state = EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS; |
1742 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1821 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1822 | read_result, | ||
1823 | EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS, | ||
1824 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1825 | EBML_READ_ELEMENT, | ||
1826 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1743 | break; | 1827 | break; |
1744 | case MatroskaID_Info: | 1828 | case MatroskaID_Info: |
1745 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS; | 1829 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS; |
1746 | clean_ebml_state_matroska_info (state); | 1830 | clean_ebml_state_matroska_info (state); |
1747 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1831 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1832 | read_result, | ||
1833 | EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS, | ||
1834 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1835 | EBML_READ_ELEMENT, | ||
1836 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1748 | break; | 1837 | break; |
1749 | case MatroskaID_Tracks: | 1838 | case MatroskaID_Tracks: |
1750 | state->next_state = EBML_READING_MATROSKA_TRACKS_CONTENTS; | 1839 | state->next_state = EBML_READING_MATROSKA_TRACKS_CONTENTS; |
1751 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1840 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1841 | read_result, | ||
1842 | EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS, | ||
1843 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1844 | EBML_READ_ELEMENT, | ||
1845 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1752 | break; | 1846 | break; |
1753 | case MatroskaID_Tags: | 1847 | case MatroskaID_Tags: |
1754 | state->next_state = EBML_READING_MATROSKA_TAGS_CONTENTS; | 1848 | state->next_state = EBML_READING_MATROSKA_TAGS_CONTENTS; |
1755 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS); | 1849 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1850 | read_result, | ||
1851 | EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS, | ||
1852 | EBML_READING_MATROSKA_SEGMENT_CONTENTS, | ||
1853 | EBML_READ_ELEMENT, | ||
1854 | EBML_READING_MATROSKA_SEGMENT_CONTENTS); | ||
1756 | break; | 1855 | break; |
1757 | default: | 1856 | default: |
1758 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1857 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1763,7 +1862,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1763 | } | 1862 | } |
1764 | break; | 1863 | break; |
1765 | case EBML_READING_MATROSKA_TAGS_CONTENTS: | 1864 | case EBML_READING_MATROSKA_TAGS_CONTENTS: |
1766 | if (!check_result (plugin, read_result, state)) | 1865 | if (! check_result (plugin, read_result, state)) |
1767 | break; | 1866 | break; |
1768 | state->state = EBML_READ_ELEMENT; | 1867 | state->state = EBML_READ_ELEMENT; |
1769 | switch (eID) | 1868 | switch (eID) |
@@ -1771,7 +1870,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1771 | case MatroskaID_Tags_Tag: | 1870 | case MatroskaID_Tags_Tag: |
1772 | state->next_state = EBML_READING_MATROSKA_TAG_CONTENTS; | 1871 | state->next_state = EBML_READING_MATROSKA_TAG_CONTENTS; |
1773 | clean_ebml_state_matroska_seek (state); | 1872 | clean_ebml_state_matroska_seek (state); |
1774 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS, EBML_READING_MATROSKA_TAGS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAGS_CONTENTS); | 1873 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1874 | read_result, | ||
1875 | EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS, | ||
1876 | EBML_READING_MATROSKA_TAGS_CONTENTS, | ||
1877 | EBML_READ_ELEMENT, | ||
1878 | EBML_READING_MATROSKA_TAGS_CONTENTS); | ||
1775 | break; | 1879 | break; |
1776 | default: | 1880 | default: |
1777 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1881 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1781,7 +1885,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1781 | } | 1885 | } |
1782 | break; | 1886 | break; |
1783 | case EBML_READING_MATROSKA_TAG_CONTENTS: | 1887 | case EBML_READING_MATROSKA_TAG_CONTENTS: |
1784 | if (!check_result (plugin, read_result, state)) | 1888 | if (! check_result (plugin, read_result, state)) |
1785 | break; | 1889 | break; |
1786 | 1890 | ||
1787 | state->state = EBML_READ_ELEMENT; | 1891 | state->state = EBML_READ_ELEMENT; |
@@ -1793,7 +1897,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1793 | matroska_add_tag (state, NULL, NULL, NULL); | 1897 | matroska_add_tag (state, NULL, NULL, NULL); |
1794 | state->tag_current = state->tag_last; | 1898 | state->tag_current = state->tag_last; |
1795 | state->tag_tree = state->tag_current; | 1899 | state->tag_tree = state->tag_current; |
1796 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_TAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAG_CONTENTS); | 1900 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1901 | read_result, | ||
1902 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1903 | EBML_READING_MATROSKA_TAG_CONTENTS, | ||
1904 | EBML_READ_ELEMENT, | ||
1905 | EBML_READING_MATROSKA_TAG_CONTENTS); | ||
1797 | break; | 1906 | break; |
1798 | default: | 1907 | default: |
1799 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 1908 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1803,7 +1912,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1803 | } | 1912 | } |
1804 | break; | 1913 | break; |
1805 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS: | 1914 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS: |
1806 | if (!check_result (plugin, read_result, state)) | 1915 | if (! check_result (plugin, read_result, state)) |
1807 | break; | 1916 | break; |
1808 | 1917 | ||
1809 | do_break = 0; | 1918 | do_break = 0; |
@@ -1823,7 +1932,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1823 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS; | 1932 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS; |
1824 | matroska_add_tag (state, state->tag_current, NULL, NULL); | 1933 | matroska_add_tag (state, state->tag_current, NULL, NULL); |
1825 | state->tag_current = state->tag_last; | 1934 | state->tag_current = state->tag_last; |
1826 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1935 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1936 | read_result, | ||
1937 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1938 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1939 | EBML_READ_ELEMENT, | ||
1940 | EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1827 | do_break = 1; | 1941 | do_break = 1; |
1828 | break; | 1942 | break; |
1829 | default: | 1943 | default: |
@@ -1838,10 +1952,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1838 | if (do_break) | 1952 | if (do_break) |
1839 | break; | 1953 | break; |
1840 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE; | 1954 | state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE; |
1841 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1955 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
1956 | EBML_BAD_STATE, | ||
1957 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, | ||
1958 | EBML_READ_ELEMENT, | ||
1959 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1842 | break; | 1960 | break; |
1843 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE: | 1961 | case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE: |
1844 | if (!check_result (plugin, read_result, state)) | 1962 | if (! check_result (plugin, read_result, state)) |
1845 | break; | 1963 | break; |
1846 | 1964 | ||
1847 | /* This breaks the specs, as there should be only one instance of each | 1965 | /* This breaks the specs, as there should be only one instance of each |
@@ -1861,10 +1979,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1861 | state->tag_current->string = strdup (string_value); | 1979 | state->tag_current->string = strdup (string_value); |
1862 | break; | 1980 | break; |
1863 | } | 1981 | } |
1864 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | 1982 | rise_up_after_value (plugin, state, |
1983 | EBML_READING_MATROSKA_SIMPLETAG_CONTENTS); | ||
1865 | break; | 1984 | break; |
1866 | case EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS: | 1985 | case EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS: |
1867 | if (!check_result (plugin, read_result, state)) | 1986 | if (! check_result (plugin, read_result, state)) |
1868 | break; | 1987 | break; |
1869 | 1988 | ||
1870 | state->state = EBML_READ_ELEMENT; | 1989 | state->state = EBML_READ_ELEMENT; |
@@ -1873,7 +1992,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1873 | case MatroskaID_Seek: | 1992 | case MatroskaID_Seek: |
1874 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS; | 1993 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS; |
1875 | clean_ebml_state_matroska_seek (state); | 1994 | clean_ebml_state_matroska_seek (state); |
1876 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS); | 1995 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
1996 | read_result, | ||
1997 | EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS, | ||
1998 | EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS, | ||
1999 | EBML_READ_ELEMENT, | ||
2000 | EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS); | ||
1877 | break; | 2001 | break; |
1878 | default: | 2002 | default: |
1879 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 2003 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1883,7 +2007,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1883 | } | 2007 | } |
1884 | break; | 2008 | break; |
1885 | case EBML_READING_MATROSKA_SEEK_CONTENTS: | 2009 | case EBML_READING_MATROSKA_SEEK_CONTENTS: |
1886 | if (!check_result (plugin, read_result, state)) | 2010 | if (! check_result (plugin, read_result, state)) |
1887 | break; | 2011 | break; |
1888 | 2012 | ||
1889 | do_break = 0; | 2013 | do_break = 0; |
@@ -1907,10 +2031,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1907 | if (do_break) | 2031 | if (do_break) |
1908 | break; | 2032 | break; |
1909 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE; | 2033 | state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE; |
1910 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_CONTENTS); | 2034 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2035 | EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS, | ||
2036 | EBML_READ_ELEMENT, | ||
2037 | EBML_READING_MATROSKA_SEEK_CONTENTS); | ||
1911 | break; | 2038 | break; |
1912 | case EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE: | 2039 | case EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE: |
1913 | if (!check_result (plugin, read_result, state)) | 2040 | if (! check_result (plugin, read_result, state)) |
1914 | break; | 2041 | break; |
1915 | 2042 | ||
1916 | /* This breaks the specs, as there should be only one instance of each | 2043 | /* This breaks the specs, as there should be only one instance of each |
@@ -1929,7 +2056,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1929 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SEEK_CONTENTS); | 2056 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SEEK_CONTENTS); |
1930 | break; | 2057 | break; |
1931 | case EBML_READING_MATROSKA_TRACKS_CONTENTS: | 2058 | case EBML_READING_MATROSKA_TRACKS_CONTENTS: |
1932 | if (!check_result (plugin, read_result, state)) | 2059 | if (! check_result (plugin, read_result, state)) |
1933 | break; | 2060 | break; |
1934 | 2061 | ||
1935 | state->state = EBML_READ_ELEMENT; | 2062 | state->state = EBML_READ_ELEMENT; |
@@ -1938,7 +2065,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1938 | case MatroskaID_Tracks_TrackEntry: | 2065 | case MatroskaID_Tracks_TrackEntry: |
1939 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS; | 2066 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS; |
1940 | clean_ebml_state_matroska_track (state); | 2067 | clean_ebml_state_matroska_track (state); |
1941 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READING_MATROSKA_TRACKS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACKS_CONTENTS); | 2068 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2069 | read_result, | ||
2070 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2071 | EBML_READING_MATROSKA_TRACKS_CONTENTS, | ||
2072 | EBML_READ_ELEMENT, | ||
2073 | EBML_READING_MATROSKA_TRACKS_CONTENTS); | ||
1942 | break; | 2074 | break; |
1943 | default: | 2075 | default: |
1944 | if (maybe_rise_up (plugin, state, &do_break, read_result)) | 2076 | if (maybe_rise_up (plugin, state, &do_break, read_result)) |
@@ -1948,7 +2080,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1948 | } | 2080 | } |
1949 | break; | 2081 | break; |
1950 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS: | 2082 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS: |
1951 | if (!check_result (plugin, read_result, state)) | 2083 | if (! check_result (plugin, read_result, state)) |
1952 | break; | 2084 | break; |
1953 | 2085 | ||
1954 | do_break = 0; | 2086 | do_break = 0; |
@@ -1967,14 +2099,24 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1967 | state->state = EBML_READ_ELEMENT; | 2099 | state->state = EBML_READ_ELEMENT; |
1968 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS; | 2100 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS; |
1969 | clean_ebml_state_matroska_track_video (state); | 2101 | clean_ebml_state_matroska_track_video (state); |
1970 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2102 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2103 | read_result, | ||
2104 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, | ||
2105 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2106 | EBML_READ_ELEMENT, | ||
2107 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1971 | do_break = 1; | 2108 | do_break = 1; |
1972 | break; | 2109 | break; |
1973 | case MatroskaID_Tracks_Audio: | 2110 | case MatroskaID_Tracks_Audio: |
1974 | state->state = EBML_READ_ELEMENT; | 2111 | state->state = EBML_READ_ELEMENT; |
1975 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS; | 2112 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS; |
1976 | clean_ebml_state_matroska_track_audio (state); | 2113 | clean_ebml_state_matroska_track_audio (state); |
1977 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2114 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, |
2115 | read_result, | ||
2116 | EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, | ||
2117 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2118 | EBML_READ_ELEMENT, | ||
2119 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1978 | do_break = 1; | 2120 | do_break = 1; |
1979 | break; | 2121 | break; |
1980 | default: | 2122 | default: |
@@ -1989,10 +2131,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
1989 | if (do_break) | 2131 | if (do_break) |
1990 | break; | 2132 | break; |
1991 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE; | 2133 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE; |
1992 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2134 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2135 | EBML_BAD_STATE, | ||
2136 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, | ||
2137 | EBML_READ_ELEMENT, | ||
2138 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
1993 | break; | 2139 | break; |
1994 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS: | 2140 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS: |
1995 | if (!check_result (plugin, read_result, state)) | 2141 | if (! check_result (plugin, read_result, state)) |
1996 | break; | 2142 | break; |
1997 | 2143 | ||
1998 | do_break = 0; | 2144 | do_break = 0; |
@@ -2017,11 +2163,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2017 | } | 2163 | } |
2018 | if (do_break) | 2164 | if (do_break) |
2019 | break; | 2165 | break; |
2020 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE; | 2166 | state->next_state = |
2021 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | 2167 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE; |
2168 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, | ||
2169 | EBML_BAD_STATE, | ||
2170 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, | ||
2171 | EBML_READ_ELEMENT, | ||
2172 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | ||
2022 | break; | 2173 | break; |
2023 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE: | 2174 | case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE: |
2024 | if (!check_result (plugin, read_result, state)) | 2175 | if (! check_result (plugin, read_result, state)) |
2025 | break; | 2176 | break; |
2026 | 2177 | ||
2027 | /* This breaks the specs, as there should be only one instance of each | 2178 | /* This breaks the specs, as there should be only one instance of each |
@@ -2043,10 +2194,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2043 | state->matroska_track_audio_bit_depth = uint_value; | 2194 | state->matroska_track_audio_bit_depth = uint_value; |
2044 | break; | 2195 | break; |
2045 | } | 2196 | } |
2046 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | 2197 | rise_up_after_value (plugin, state, |
2198 | EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS); | ||
2047 | break; | 2199 | break; |
2048 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS: | 2200 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS: |
2049 | if (!check_result (plugin, read_result, state)) | 2201 | if (! check_result (plugin, read_result, state)) |
2050 | break; | 2202 | break; |
2051 | 2203 | ||
2052 | do_break = 0; | 2204 | do_break = 0; |
@@ -2072,11 +2224,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2072 | } | 2224 | } |
2073 | if (do_break) | 2225 | if (do_break) |
2074 | break; | 2226 | break; |
2075 | state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE; | 2227 | state->next_state = |
2076 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | 2228 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE; |
2229 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, | ||
2230 | EBML_BAD_STATE, | ||
2231 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, | ||
2232 | EBML_READ_ELEMENT, | ||
2233 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | ||
2077 | break; | 2234 | break; |
2078 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE: | 2235 | case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE: |
2079 | if (!check_result (plugin, read_result, state)) | 2236 | if (! check_result (plugin, read_result, state)) |
2080 | break; | 2237 | break; |
2081 | 2238 | ||
2082 | /* This breaks the specs, as there should be only one instance of each | 2239 | /* This breaks the specs, as there should be only one instance of each |
@@ -2107,10 +2264,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2107 | state->matroska_track_video_display_unit = uint_value; | 2264 | state->matroska_track_video_display_unit = uint_value; |
2108 | break; | 2265 | break; |
2109 | } | 2266 | } |
2110 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | 2267 | rise_up_after_value (plugin, state, |
2268 | EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS); | ||
2111 | break; | 2269 | break; |
2112 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE: | 2270 | case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE: |
2113 | if (!check_result (plugin, read_result, state)) | 2271 | if (! check_result (plugin, read_result, state)) |
2114 | break; | 2272 | break; |
2115 | 2273 | ||
2116 | /* This breaks the specs, as there should be only one instance of each | 2274 | /* This breaks the specs, as there should be only one instance of each |
@@ -2143,10 +2301,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2143 | state->matroska_track_codec_name = strdup (string_value); | 2301 | state->matroska_track_codec_name = strdup (string_value); |
2144 | break; /* UTF-8-encoded. A human-readable string specifying the codec. */ | 2302 | break; /* UTF-8-encoded. A human-readable string specifying the codec. */ |
2145 | } | 2303 | } |
2146 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | 2304 | rise_up_after_value (plugin, state, |
2305 | EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS); | ||
2147 | break; | 2306 | break; |
2148 | case EBML_READING_MATROSKA_INFO_CONTENTS: | 2307 | case EBML_READING_MATROSKA_INFO_CONTENTS: |
2149 | if (!check_result (plugin, read_result, state)) | 2308 | if (! check_result (plugin, read_result, state)) |
2150 | break; | 2309 | break; |
2151 | 2310 | ||
2152 | do_break = 0; | 2311 | do_break = 0; |
@@ -2178,10 +2337,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2178 | if (do_break) | 2337 | if (do_break) |
2179 | break; | 2338 | break; |
2180 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS_VALUE; | 2339 | state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS_VALUE; |
2181 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_INFO_CONTENTS); | 2340 | ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, |
2341 | EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS, | ||
2342 | EBML_READ_ELEMENT, | ||
2343 | EBML_READING_MATROSKA_INFO_CONTENTS); | ||
2182 | break; | 2344 | break; |
2183 | case EBML_READING_MATROSKA_INFO_CONTENTS_VALUE: | 2345 | case EBML_READING_MATROSKA_INFO_CONTENTS_VALUE: |
2184 | if (!check_result (plugin, read_result, state)) | 2346 | if (! check_result (plugin, read_result, state)) |
2185 | break; | 2347 | break; |
2186 | 2348 | ||
2187 | /* This breaks the specs, as there should be only one instance of each | 2349 | /* This breaks the specs, as there should be only one instance of each |
@@ -2219,7 +2381,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2219 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_INFO_CONTENTS); | 2381 | rise_up_after_value (plugin, state, EBML_READING_MATROSKA_INFO_CONTENTS); |
2220 | break; | 2382 | break; |
2221 | case EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS: | 2383 | case EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS: |
2222 | if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 2384 | if ((state->stack_top != NULL) && (pl_get_pos (plugin) >= |
2385 | state->stack_top->position | ||
2386 | + state->stack_top->header_size | ||
2387 | + state->stack_top->size) ) | ||
2223 | report_state (state, proc, proc_cls); | 2388 | report_state (state, proc, proc_cls); |
2224 | maybe_seek_to_something_interesting (plugin, state); | 2389 | maybe_seek_to_something_interesting (plugin, state); |
2225 | state->state = EBML_READ_ELEMENT; | 2390 | state->state = EBML_READ_ELEMENT; |
@@ -2227,7 +2392,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2227 | free (ebml_stack_pop (state)); | 2392 | free (ebml_stack_pop (state)); |
2228 | break; | 2393 | break; |
2229 | case EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS: | 2394 | case EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS: |
2230 | if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size) | 2395 | if ((state->stack_top != NULL) && (pl_get_pos (plugin) >= |
2396 | state->stack_top->position | ||
2397 | + state->stack_top->header_size | ||
2398 | + state->stack_top->size) ) | ||
2231 | report_state (state, proc, proc_cls); | 2399 | report_state (state, proc, proc_cls); |
2232 | state->state = EBML_READ_ELEMENT; | 2400 | state->state = EBML_READ_ELEMENT; |
2233 | state->next_state = state->stack_top->prev_state; | 2401 | state->next_state = state->stack_top->prev_state; |
@@ -2235,7 +2403,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me | |||
2235 | break; | 2403 | break; |
2236 | case EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS: | 2404 | case EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS: |
2237 | if ((state->matroska_seek_id != 0) && | 2405 | if ((state->matroska_seek_id != 0) && |
2238 | ((state->matroska_seek_position > 0) || state->matroska_seeks_tail == NULL)) | 2406 | ((state->matroska_seek_position > 0) || (state->matroska_seeks_tail == |
2407 | NULL) )) | ||
2239 | { | 2408 | { |
2240 | struct matroska_seek_list *el; | 2409 | struct matroska_seek_list *el; |
2241 | el = malloc (sizeof (struct matroska_seek_list)); | 2410 | el = malloc (sizeof (struct matroska_seek_list)); |