added first part of ass parser.
This commit is contained in:
parent
57474c1e4e
commit
503e803d47
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
CC=i586-mingw32msvc-gcc
|
CC=i586-mingw32msvc-gcc
|
||||||
CFLAGS=-O3 -Iinc/ -Wall -DLE_ARCH
|
CFLAGS=-O3 -Iinc/ -Wall -DLE_ARCH
|
||||||
LDFLAGS=-lpng -lz -lvfw32 -Llib/ -liberty
|
LDFLAGS=-lpng -lz -lvfw32 -Llib/ -liberty
|
||||||
OBJS=avs2bdnxml.o auto_split.o palletize.o sup.o sort.o
|
OBJS=avs2bdnxml.o auto_split.o palletize.o sup.o sort.o ass.o
|
||||||
ASMOBJS=frame-a.o
|
ASMOBJS=frame-a.o
|
||||||
EXE=avs2bdnxml.exe
|
EXE=avs2bdnxml.exe
|
||||||
|
|
||||||
|
64
ass.c
Normal file
64
ass.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* avs2bdnxml - Generates BluRay subtitle stuff from RGBA AviSynth scripts
|
||||||
|
* Copyright (C) 2008-2013 Arne Bochem <avs2bdnxml at ps-auxw de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "ass.h"
|
||||||
|
#include "abstract_lists.h"
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
|
#define DEBUG 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void parse_ass(char *filename)
|
||||||
|
{
|
||||||
|
char l[BUFSIZ];
|
||||||
|
char p[128];
|
||||||
|
int start[4], end[4];
|
||||||
|
FILE *fh;
|
||||||
|
|
||||||
|
if ((fh = fopen(filename, "r")) == NULL)
|
||||||
|
{
|
||||||
|
perror("Error opening input ASS file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (fgets(l, BUFSIZ - 1, fh) != NULL) {
|
||||||
|
i++;
|
||||||
|
if (l[0] == 0 || l[0] == '\n' || l[0] == '\r')
|
||||||
|
continue;
|
||||||
|
size_t x = sscanf(l, "Dialogue: %*d,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s[127]", &start[0], &start[1], &start[2], &start[3], &end[0], &end[1], &end[2], &end[3], p);
|
||||||
|
if (x == 9) {
|
||||||
|
char *subchar_start = strstr(p, ",");
|
||||||
|
if (subchar_start == NULL) {
|
||||||
|
printf("Error while parsing ASS in line %d - no ',' found after end timestamp.", i);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
subchar_start++;
|
||||||
|
if (subchar_start[0] == '!') {
|
||||||
|
printf("%d forced!\n", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fh);
|
||||||
|
}
|
44
ass.h
Normal file
44
ass.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* avs2bdnxml - Generates BluRay subtitle stuff from RGBA AviSynth scripts
|
||||||
|
* Copyright (C) 2008-2010 Arne Bochem <avs2bdnxml at ps-auxw de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef SUP_H
|
||||||
|
#define SUP_H
|
||||||
|
|
||||||
|
#include "abstract_lists.h"
|
||||||
|
|
||||||
|
typedef struct ass_sub_info_s
|
||||||
|
{
|
||||||
|
int start;
|
||||||
|
int end;
|
||||||
|
int forced;
|
||||||
|
} ass_sub_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
DECLARE_LIST(asi, ass_sub_info_t)
|
||||||
|
|
||||||
|
typedef struct ass_reader_s
|
||||||
|
{
|
||||||
|
FILE *fh;
|
||||||
|
asi_list_t *asil;
|
||||||
|
} ass_reader_t;
|
||||||
|
|
||||||
|
|
||||||
|
void parse_ass(char *filename);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user