* Format: * MkvVobSubtitlePrivateData = ( Line )* * Line = FieldName ':' ' ' FieldValue '\n' * FieldName = [^:]+ * FieldValue = [^\n]+ * * The line of interest is: * PaletteLine = "palette" ':' ' ' RRGGBB ( ',' ' ' RRGGBB )* * * More information on the format at: * http://www.matroska.org/technical/specs/subtitles/images.html */
| 5658 | * http://www.matroska.org/technical/specs/subtitles/images.html |
| 5659 | */ |
| 5660 | static int ffmpeg_parse_vobsub_extradata_mkv( AVCodecParameters *codecpar, |
| 5661 | hb_subtitle_t *subtitle ) |
| 5662 | { |
| 5663 | // lines = (string) codecpar->extradata; |
| 5664 | char *lines = malloc( codecpar->extradata_size + 1 ); |
| 5665 | if ( lines == NULL ) |
| 5666 | return 1; |
| 5667 | memcpy( lines, codecpar->extradata, codecpar->extradata_size ); |
| 5668 | lines[codecpar->extradata_size] = '\0'; |
| 5669 | |
| 5670 | uint32_t rgb[16]; |
| 5671 | int gotPalette = 0; |
| 5672 | int gotDimensions = 0; |
| 5673 | |
| 5674 | char *curLine, *curLine_parserData; |
| 5675 | for ( curLine = strtok_r( lines, "\n", &curLine_parserData ); |
| 5676 | curLine; |
| 5677 | curLine = strtok_r( NULL, "\n", &curLine_parserData ) ) |
| 5678 | { |
| 5679 | if (!gotPalette) |
| 5680 | { |
| 5681 | int numElementsRead = sscanf(curLine, "palette: " |
| 5682 | "%06x, %06x, %06x, %06x, " |
| 5683 | "%06x, %06x, %06x, %06x, " |
| 5684 | "%06x, %06x, %06x, %06x, " |
| 5685 | "%06x, %06x, %06x, %06x", |
| 5686 | &rgb[0], &rgb[1], &rgb[2], &rgb[3], |
| 5687 | &rgb[4], &rgb[5], &rgb[6], &rgb[7], |
| 5688 | &rgb[8], &rgb[9], &rgb[10], &rgb[11], |
| 5689 | &rgb[12], &rgb[13], &rgb[14], &rgb[15]); |
| 5690 | |
| 5691 | if (numElementsRead == 16) { |
| 5692 | gotPalette = 1; |
| 5693 | } |
| 5694 | } |
| 5695 | if (!gotDimensions) |
| 5696 | { |
| 5697 | int numElementsRead = sscanf(curLine, "size: %dx%d", |
| 5698 | &subtitle->width, &subtitle->height); |
| 5699 | |
| 5700 | if (numElementsRead == 2) { |
| 5701 | gotDimensions = 1; |
| 5702 | } |
| 5703 | } |
| 5704 | if (gotPalette && gotDimensions) |
| 5705 | break; |
| 5706 | } |
| 5707 | |
| 5708 | if (subtitle->width == 0 || subtitle->height == 0) |
| 5709 | { |
| 5710 | subtitle->width = 720; |
| 5711 | subtitle->height = 480; |
| 5712 | } |
| 5713 | |
| 5714 | free( lines ); |
| 5715 | |
| 5716 | if ( gotPalette ) |
| 5717 | { |
no test coverage detected