Merge lp:~noskcaj/ubuntu/trusty/subtitleripper/merge into lp:ubuntu/trusty/subtitleripper

Proposed by Jackson Doak
Status: Needs review
Proposed branch: lp:~noskcaj/ubuntu/trusty/subtitleripper/merge
Merge into: lp:ubuntu/trusty/subtitleripper
Diff against target: 2544 lines (+2083/-210)
32 files modified
.pc/.quilt_patches (+1/-0)
.pc/.quilt_series (+1/-0)
.pc/.version (+1/-0)
.pc/01_pgm2txt.patch/pgm2txt (+178/-0)
.pc/02_Makefile.patch/Makefile (+116/-0)
.pc/03_binutils-gold.patch/Makefile (+116/-0)
.pc/03_getline.diff/vobsub.c (+1264/-0)
.pc/applied-patches (+4/-0)
Makefile (+5/-5)
debian/README.source (+2/-0)
debian/changelog (+29/-0)
debian/compat (+1/-1)
debian/control (+7/-5)
debian/copyright (+1/-1)
debian/docs (+1/-0)
debian/install (+7/-0)
debian/manpages (+1/-0)
debian/patches/00list (+0/-3)
debian/patches/01_pgm2txt.dpatch (+0/-59)
debian/patches/01_pgm2txt.patch (+51/-0)
debian/patches/02_Makefile.dpatch (+0/-29)
debian/patches/02_Makefile.patch (+67/-0)
debian/patches/03_binutils-gold.dpatch (+0/-33)
debian/patches/03_binutils-gold.patch (+34/-0)
debian/patches/03_getline.diff (+13/-0)
debian/patches/series (+4/-0)
debian/rules (+6/-66)
debian/source/format (+1/-0)
debian/subtitle2pgm.1 (+163/-0)
debian/watch (+1/-0)
pgm2txt (+7/-7)
vobsub.c (+1/-1)
To merge this branch: bzr merge lp:~noskcaj/ubuntu/trusty/subtitleripper/merge
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+195853@code.launchpad.net

Description of the change

Merge from deb-multimedia. Ignore the bzr log.

To post a comment you must log in.
Revision history for this message
Daniel Holbach (dholbach) wrote :

Uploaded. Thanks.

review: Approve

Unmerged revisions

11. By Jackson Doak

Fix typo with noticeable in changelog

10. By Jackson Doak

* Change noticable to noticeable in manpage
* Diable silent building

9. By Jackson Doak

add quilt's files

8. By Jackson Doak

Add files from merge

7. By Jackson Doak

Merge from deb-multimedia

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc'
2=== added file '.pc/.quilt_patches'
3--- .pc/.quilt_patches 1970-01-01 00:00:00 +0000
4+++ .pc/.quilt_patches 2013-11-19 19:50:12 +0000
5@@ -0,0 +1,1 @@
6+debian/patches
7
8=== added file '.pc/.quilt_series'
9--- .pc/.quilt_series 1970-01-01 00:00:00 +0000
10+++ .pc/.quilt_series 2013-11-19 19:50:12 +0000
11@@ -0,0 +1,1 @@
12+series
13
14=== added file '.pc/.version'
15--- .pc/.version 1970-01-01 00:00:00 +0000
16+++ .pc/.version 2013-11-19 19:50:12 +0000
17@@ -0,0 +1,1 @@
18+2
19
20=== added directory '.pc/01_pgm2txt.patch'
21=== added file '.pc/01_pgm2txt.patch/pgm2txt'
22--- .pc/01_pgm2txt.patch/pgm2txt 1970-01-01 00:00:00 +0000
23+++ .pc/01_pgm2txt.patch/pgm2txt 2013-11-19 19:50:12 +0000
24@@ -0,0 +1,178 @@
25+#!/bin/sh
26+# Call gocr to convert pgm images into ASCII text
27+# (this file is part of subtitle2pgm)
28+# Please modify it to your needs
29+#set -x
30+
31+# Exit script on Control-C (signal 2)
32+trap 'echo "Control-C pressed."; exit 1;' 2
33+
34+###### Configuration section #################
35+
36+# If you already have a GOCR database adjust.
37+# If in doubt, keep the default
38+DB_PATH=./db/
39+
40+# Adjust this path to where the files
41+# gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed
42+# are located
43+PATH_TO_LANGUAGE_FILTER=~/sourceforge/subtitleripper/src/
44+
45+# set your options for gocr. Please read the gocr
46+# docs to find out more about this
47+
48+# GOCR options for pure data base mode
49+GOCR_OPTIONS_DB_ONLY="-s 8 -d 0 -m 130 -m 4 -m 256 -m 32"
50+
51+# GOCR options for with automatic char recognition
52+GOCR_OPTIONS_AUTO="-s 10 -m 130"
53+
54+# Select the language of the default filter.
55+# use -f command line option to override this
56+# valid are: none, en, fr
57+LANGUAGE=none
58+
59+# Choose your favorite image viewer if you want to see
60+# the current pgm image while gocr is running.
61+# Enable the viewer with -v command line option.
62+IMAGE_VIWER=xv
63+IMAGE_VIEWER_OPTIONS=-q
64+
65+###### End of configuration section #########
66+
67+
68+DISPLAY_PGM=false
69+
70+# function to print usage information
71+usage()
72+{
73+cat << _END_
74+Usage:
75+ pgm2txt [-v] [-d] [-f {en|fr|none}] pgm_base_name
76+
77+ pgm_base_name are the common first letters of your
78+ subtitle pgm files. E.g. "my_movie" if all your pgm files
79+ are matched by "my_movie*.pgm"
80+
81+ -f lang You can optionally specify a language filter
82+ using this option. Currently English,
83+ French and German are supported.
84+ lang = {en|fr|de|none}
85+ default: none
86+
87+ -v View the pgm-file while GOCR is converting
88+
89+ -d Use GOCR options for "database only" mode
90+
91+
92+ Example:
93+ Convert PGM files with english language filter and
94+ view the PGM while GOCR is converting
95+
96+ pgm2txt -v -f en my_movie
97+
98+
99+ Version: 0.13
100+_END_
101+exit 1
102+}
103+
104+# if no argument is given display usage information
105+if [ $# -eq 0 ]; then
106+ usage
107+fi
108+
109+# set default GOCR options to auto
110+GOCR_OPTIONS=${GOCR_OPTIONS_AUTO}
111+
112+# process command line options
113+while getopts ":vdf:" Option
114+do
115+ case $Option in
116+ v)
117+ DISPLAY_PGM=true
118+ ;;
119+ f)
120+ LANGUAGE=$OPTARG
121+ ;;
122+ d)
123+ GOCR_OPTIONS=${GOCR_OPTIONS_DB_ONLY}
124+ ;;
125+ *)
126+ usage
127+ ;;
128+ esac
129+done
130+
131+# The first argument that is not an option is the pgm file basename
132+shift $(($OPTIND - 1))
133+PGM_BASE_NAME=$1
134+
135+if [ -f ${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed ]; then
136+ FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed
137+ echo "Using ${FILTER_SCRIPT} to filter gocr output"
138+else
139+ echo " ------------------------------------------------"
140+ echo " No filter file for language >${LANGUAGE}< found!"
141+ echo " Please edit PATH_TO_LANGUAGE_FILTER in pgm2txt"
142+ echo " and make sure you have choosen a valid language!"
143+ echo " No spell checking activated! "
144+ echo " ------------------------------------------------"
145+ LANGUAGE=none
146+fi
147+
148+
149+# Check if gocr is in the search path
150+GOCR_TEST_PATH=`which gocr`
151+if [ ! -x "${GOCR_TEST_PATH}" -a ! -L "${GOCR_TEST_PATH}" ]; then
152+ echo " ------------------------------------------------ "
153+ echo " Cannot find gocr ! "
154+ echo " Please make sure you have installed gocr and "
155+ echo " add it to your search path. "
156+ echo " ------------------------------------------------ "
157+ exit 1
158+fi
159+
160+# create a local db file if it does'n exist
161+if [ ! -d ${DB_PATH} ]; then
162+ echo creating directory ${DB_PATH}
163+ mkdir ${DB_PATH}
164+fi
165+
166+if [ ! -f ${DB_PATH}/db.lst ]; then
167+ echo creating empty file ${DB_PATH}/db.lst
168+ touch ${DB_PATH}/db.lst
169+fi
170+
171+# run gocr on all pgm files
172+for i in ${PGM_BASE_NAME}*.pgm ${PGM_BASE_NAME}*.pgm.gz; do
173+ if [ ! -f $i ]; then
174+ echo "File $i not found"
175+ continue
176+ fi
177+
178+ echo "Converting $i into text"
179+ if [ ! "$DISPLAY_PGM" = "false" ]; then
180+ ${IMAGE_VIWER} ${IMAGE_VIEWER_OPTIONS} $i &
181+ fi
182+ if [ "none" = "${LANGUAGE}" ]; then
183+ gocr ${GOCR_OPTIONS} -p ${DB_PATH} $i > $i.txt
184+ else
185+ gocr ${GOCR_OPTIONS} -p ${DB_PATH} $i | sed -f ${FILTER_SCRIPT} - > $i.txt
186+ fi
187+
188+ # close the viewer
189+ if [ ! "$DISPLAY_PGM" = "false" ]; then
190+ killall ${IMAGE_VIWER}
191+ fi
192+
193+done
194+
195+
196+
197+
198+
199+
200+
201+
202+
203
204=== added directory '.pc/02_Makefile.patch'
205=== added file '.pc/02_Makefile.patch/Makefile'
206--- .pc/02_Makefile.patch/Makefile 1970-01-01 00:00:00 +0000
207+++ .pc/02_Makefile.patch/Makefile 2013-11-19 19:50:12 +0000
208@@ -0,0 +1,116 @@
209+#
210+# Makefile for subtitle2pgm + srttool
211+#
212+
213+# use always:
214+DEFINES :=
215+LIBS := -lm
216+INCLUDES :=
217+
218+### enable ppm support ###
219+DEFINES += -D_HAVE_LIB_PPM_
220+LIBS += -lppm
221+
222+### enable PNG support ###
223+DEFINES += -D_HAVE_PNG_
224+LIBS += -lpng
225+
226+### enable zlib support ###
227+DEFINES += -D_HAVE_ZLIB_
228+LIBS += -lz
229+
230+CC = gcc
231+WARN = -Wall -Wstrict-prototypes
232+COPT = -g -O2
233+
234+CFLAGS = $(COPT) $(WARN) $(DEFINES) $(INCLUDES)
235+
236+# list of all files that are part of the package
237+PACKAGE_FILES = Makefile \
238+ subtitle2pgm.c subtitle2pgm.h spudec.c spudec.h \
239+ srttool.c \
240+ vobsub.c vobsub.h subtitle2vobsub.c \
241+ pgm2txt \
242+ gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed \
243+ gocrfilter_nl.sed \
244+ README README.gocr README.srttool \
245+ README.subtitle2pgm README.vobsub \
246+ ChangeLog\
247+ subtitleripper.spec\
248+ vobsub2pgm.c
249+
250+# Name of the package
251+PACKAGE = subtitleripper
252+
253+# version number
254+#VERSION = `date +%Y%m%d`
255+VERSION=0.3
256+RELEASE=4
257+
258+# Main targets
259+
260+TARGETS = subtitle2pgm srttool subtitle2vobsub vobsub2pgm
261+
262+all: $(TARGETS)
263+
264+# Generic Rules
265+
266+%.o:%.c
267+ @echo Compiling $<
268+ @$(CC) -c $(CFLAGS) $<
269+
270+# Dependencies
271+subtitle2pgm.o: subtitle2pgm.c spudec.h subtitle2pgm.h
272+spudec.o: spudec.c spudec.h
273+
274+subtitle2vobsub.o: subtitle2vobsub.c vobsub.c vobsub.h
275+
276+vobsub2pgm.o: vobsub2pgm.c vobsub.h spudec.h
277+
278+# Target
279+subtitle2pgm: subtitle2pgm.o spudec.o
280+ @echo "Linking $@"
281+ @$(CC) $(LIBS) $^ -o $@
282+
283+subtitle2vobsub: subtitle2vobsub.o vobsub.o
284+ @echo "Linking $@"
285+ @$(CC) $(LIBS) $^ -o $@
286+
287+srttool: srttool.o
288+ @echo "Linking $@"
289+ @$(CC) $(LIBS) -g $^ -o $@
290+
291+vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
292+ @echo "Linking $@"
293+ @$(CC) $(LIBS) -g $^ -o $@
294+
295+.PHONY: clean dist rpm
296+clean:
297+ rm -f $(TARGETS) subtitle2pgm.o spudec.o srttool.o vobsub.o *~
298+
299+# Build a tgz package used for upload to sourceforge
300+dist:
301+ @mkdir $(PACKAGE)
302+ @cp $(PACKAGE_FILES) $(PACKAGE)
303+ @tar cvzf $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(PACKAGE)
304+ @rm -rf $(PACKAGE)
305+ @mv $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(HOME)/
306+
307+# Build a rpm package (tested for SuSE 7.3)
308+rpm:
309+ @mkdir $(PACKAGE)
310+ @cp $(PACKAGE_FILES) $(PACKAGE)
311+ @tar cvzf $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(PACKAGE)
312+ @chmod a+rw $(PACKAGE)-$(VERSION)-$(RELEASE).tgz
313+ @rm -rf $(PACKAGE)
314+ sudo cp $(PACKAGE)-$(VERSION)-$(RELEASE).tgz /usr/src/packages/SOURCES/
315+ @rm $(PACKAGE)-$(VERSION)-$(RELEASE).tgz
316+ sudo cp subtitleripper.spec /usr/src/packages/SPECS/
317+ sudo rpm -ba /usr/src/packages/SPECS/subtitleripper.spec
318+
319+
320+
321+
322+
323+
324+
325
326=== added directory '.pc/03_binutils-gold.patch'
327=== added file '.pc/03_binutils-gold.patch/Makefile'
328--- .pc/03_binutils-gold.patch/Makefile 1970-01-01 00:00:00 +0000
329+++ .pc/03_binutils-gold.patch/Makefile 2013-11-19 19:50:12 +0000
330@@ -0,0 +1,116 @@
331+#
332+# Makefile for subtitle2pgm + srttool
333+#
334+
335+# use always:
336+DEFINES :=
337+LIBS := -lm
338+INCLUDES :=
339+
340+### enable ppm support ###
341+DEFINES += -D_HAVE_LIB_PPM_
342+LIBS += -lnetpbm
343+
344+### enable PNG support ###
345+DEFINES += -D_HAVE_PNG_
346+LIBS += -lpng
347+
348+### enable zlib support ###
349+DEFINES += -D_HAVE_ZLIB_
350+LIBS += -lz
351+
352+CC = gcc
353+WARN = -Wall -Wstrict-prototypes
354+COPT = -g -O2
355+
356+CFLAGS = $(COPT) $(WARN) $(DEFINES) $(INCLUDES)
357+
358+# list of all files that are part of the package
359+PACKAGE_FILES = Makefile \
360+ subtitle2pgm.c subtitle2pgm.h spudec.c spudec.h \
361+ srttool.c \
362+ vobsub.c vobsub.h subtitle2vobsub.c \
363+ pgm2txt \
364+ gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed \
365+ gocrfilter_nl.sed \
366+ README README.gocr README.srttool \
367+ README.subtitle2pgm README.vobsub \
368+ ChangeLog\
369+ subtitleripper.spec\
370+ vobsub2pgm.c
371+
372+# Name of the package
373+PACKAGE = subtitleripper
374+
375+# version number
376+#VERSION = `date +%Y%m%d`
377+VERSION=0.3
378+RELEASE=4
379+
380+# Main targets
381+
382+TARGETS = subtitle2pgm srttool subtitle2vobsub vobsub2pgm
383+
384+all: $(TARGETS)
385+
386+# Generic Rules
387+
388+%.o:%.c
389+ @echo Compiling $<
390+ @$(CC) -c $(CFLAGS) $<
391+
392+# Dependencies
393+subtitle2pgm.o: subtitle2pgm.c spudec.h subtitle2pgm.h
394+spudec.o: spudec.c spudec.h
395+
396+subtitle2vobsub.o: subtitle2vobsub.c vobsub.c vobsub.h
397+
398+vobsub2pgm.o: vobsub2pgm.c vobsub.h spudec.h
399+
400+# Target
401+subtitle2pgm: subtitle2pgm.o spudec.o
402+ @echo "Linking $@"
403+ @$(CC) $(LIBS) $^ -o $@
404+
405+subtitle2vobsub: subtitle2vobsub.o vobsub.o
406+ @echo "Linking $@"
407+ @$(CC) $(LIBS) $^ -o $@
408+
409+srttool: srttool.o
410+ @echo "Linking $@"
411+ @$(CC) $(LIBS) -g $^ -o $@
412+
413+vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
414+ @echo "Linking $@"
415+ @$(CC) $(LIBS) -g $^ -o $@
416+
417+.PHONY: clean dist rpm
418+clean:
419+ rm -f $(TARGETS) subtitle2pgm.o spudec.o srttool.o vobsub.o *~
420+
421+# Build a tgz package used for upload to sourceforge
422+dist:
423+ @mkdir $(PACKAGE)
424+ @cp $(PACKAGE_FILES) $(PACKAGE)
425+ @tar cvzf $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(PACKAGE)
426+ @rm -rf $(PACKAGE)
427+ @mv $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(HOME)/
428+
429+# Build a rpm package (tested for SuSE 7.3)
430+rpm:
431+ @mkdir $(PACKAGE)
432+ @cp $(PACKAGE_FILES) $(PACKAGE)
433+ @tar cvzf $(PACKAGE)-$(VERSION)-$(RELEASE).tgz $(PACKAGE)
434+ @chmod a+rw $(PACKAGE)-$(VERSION)-$(RELEASE).tgz
435+ @rm -rf $(PACKAGE)
436+ sudo cp $(PACKAGE)-$(VERSION)-$(RELEASE).tgz /usr/src/packages/SOURCES/
437+ @rm $(PACKAGE)-$(VERSION)-$(RELEASE).tgz
438+ sudo cp subtitleripper.spec /usr/src/packages/SPECS/
439+ sudo rpm -ba /usr/src/packages/SPECS/subtitleripper.spec
440+
441+
442+
443+
444+
445+
446+
447
448=== added directory '.pc/03_getline.diff'
449=== added file '.pc/03_getline.diff/vobsub.c'
450--- .pc/03_getline.diff/vobsub.c 1970-01-01 00:00:00 +0000
451+++ .pc/03_getline.diff/vobsub.c 2013-11-19 19:50:12 +0000
452@@ -0,0 +1,1264 @@
453+/*
454+ * This file is copied from the mplayer distribution
455+ * http://mplayer.dev.hu/homepage/news.html
456+ * (original file vobsub.c)
457+ *
458+ * Thanks to the original author (who ever he/she is).
459+ *
460+ *
461+ * History:
462+ * 2002-08-09
463+ * File stolen from MPlayer 0.90pre6-2.95.3
464+ * and modified to run through gcc
465+ * File is identical to mplayer CVS version 1.18
466+ */
467+
468+
469+/*
470+ * Some code freely inspired from VobSub <URL:http://vobsub.edensrising.com>,
471+ * with kind permission from Gabest <gabest@freemail.hu>
472+ */
473+/* #define HAVE_GETLINE */
474+#include <ctype.h>
475+#include <errno.h>
476+#include <stdio.h>
477+#include <stdlib.h>
478+#include <string.h>
479+#include <fcntl.h>
480+#include <unistd.h>
481+#include <sys/stat.h>
482+#include <sys/types.h>
483+
484+//#include "config.h"
485+//#include "version.h"
486+#define VERSION "0.90pre6-2.95.3 (subtitleripper)"
487+
488+#include "vobsub.h"
489+
490+//#include "libvo/video_out.h"
491+#include "spudec.h"
492+
493+//#include "mp_msg.h"
494+#define mp_msg(a,b,args...) fprintf(stderr,##args),putc('\n',stderr)
495+#define spudec_new_scaled_vobsub(a, b, c, d, e) (void*) printf("BUG:spudec_new_scaled_vobsub called\n")
496+
497+
498+#define MIN(a, b) ((a)<(b)?(a):(b))
499+#define MAX(a, b) ((a)>(b)?(a):(b))
500+
501+extern int vobsub_id;
502+
503+extern int verbose;
504+
505+#ifdef HAVE_GETLINE
506+extern ssize_t getline(char **, size_t *, FILE *);
507+#else
508+/* FIXME This should go into a general purpose library or even a
509+ separate file. */
510+static ssize_t
511+getline (char **lineptr, size_t *n, FILE *stream)
512+{
513+ size_t res = 0;
514+ int c;
515+ if (*lineptr == NULL) {
516+ *lineptr = malloc(4096);
517+ if (*lineptr)
518+ *n = 4096;
519+ }
520+ else if (*n == 0) {
521+ char *tmp = realloc(*lineptr, 4096);
522+ if (tmp) {
523+ *lineptr = tmp;
524+ *n = 4096;
525+ }
526+ }
527+ if (*lineptr == NULL || *n == 0)
528+ return -1;
529+
530+ for (c = fgetc(stream); c != EOF; c = fgetc(stream)) {
531+ if (res + 1 >= *n) {
532+ char *tmp = realloc(*lineptr, *n * 2);
533+ if (tmp == NULL)
534+ return -1;
535+ *lineptr = tmp;
536+ *n *= 2;
537+ }
538+ (*lineptr)[res++] = c;
539+ if (c == '\n') {
540+ (*lineptr)[res] = 0;
541+ return res;
542+ }
543+ }
544+ if (res == 0)
545+ return -1;
546+ (*lineptr)[res] = 0;
547+ return res;
548+}
549+#endif
550+
551+/**********************************************************************
552+ * MPEG parsing
553+ **********************************************************************/
554+
555+typedef struct {
556+ FILE *stream;
557+ unsigned int pts;
558+ int aid;
559+ unsigned char *packet;
560+ unsigned int packet_reserve;
561+ unsigned int packet_size;
562+} mpeg_t;
563+
564+static mpeg_t *
565+mpeg_open(const char *filename)
566+{
567+ mpeg_t *res = malloc(sizeof(mpeg_t));
568+ int err = res == NULL;
569+ if (!err) {
570+ res->pts = 0;
571+ res->aid = -1;
572+ res->packet = NULL;
573+ res->packet_size = 0;
574+ res->packet_reserve = 0;
575+ res->stream = fopen(filename, "r");
576+ err = res->stream == NULL;
577+ if (err)
578+ perror("fopen Vobsub file failed");
579+ if (err)
580+ free(res);
581+ }
582+ return err ? NULL : res;
583+}
584+
585+static void
586+mpeg_free(mpeg_t *mpeg)
587+{
588+ if (mpeg->packet)
589+ free(mpeg->packet);
590+ if (mpeg->stream)
591+ fclose(mpeg->stream);
592+ free(mpeg);
593+}
594+
595+static int
596+mpeg_eof(mpeg_t *mpeg)
597+{
598+ return feof(mpeg->stream);
599+}
600+
601+static off_t
602+mpeg_tell(mpeg_t *mpeg)
603+{
604+ return ftell(mpeg->stream);
605+}
606+
607+static int
608+mpeg_run(mpeg_t *mpeg)
609+{
610+ unsigned int len, idx, version;
611+ int c;
612+ /* Goto start of a packet, it starts with 0x000001?? */
613+ const unsigned char wanted[] = { 0, 0, 1 };
614+ unsigned char buf[5];
615+
616+ mpeg->aid = -1;
617+ mpeg->packet_size = 0;
618+ if (fread(buf, 4, 1, mpeg->stream) != 1)
619+ return -1;
620+ while (memcmp(buf, wanted, sizeof(wanted)) != 0) {
621+ c = getc(mpeg->stream);
622+ if (c < 0)
623+ return -1;
624+ memmove(buf, buf + 1, 3);
625+ buf[3] = c;
626+ }
627+ switch (buf[3]) {
628+ case 0xb9: /* System End Code */
629+ break;
630+ case 0xba: /* Packet start code */
631+ c = getc(mpeg->stream);
632+ if (c < 0)
633+ return -1;
634+ if ((c & 0xc0) == 0x40)
635+ version = 4;
636+ else if ((c & 0xf0) == 0x20)
637+ version = 2;
638+ else {
639+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Unsupported MPEG version: 0x%02x", c);
640+ return -1;
641+ }
642+ if (version == 4) {
643+ if (fseek(mpeg->stream, 9, SEEK_CUR))
644+ return -1;
645+ }
646+ else if (version == 2) {
647+ if (fseek(mpeg->stream, 7, SEEK_CUR))
648+ return -1;
649+ }
650+ else
651+ abort();
652+ break;
653+ case 0xbd: /* packet */
654+ if (fread(buf, 2, 1, mpeg->stream) != 1)
655+ return -1;
656+ len = buf[0] << 8 | buf[1];
657+ idx = mpeg_tell(mpeg);
658+ c = getc(mpeg->stream);
659+ if (c < 0)
660+ return -1;
661+ if ((c & 0xC0) == 0x40) { /* skip STD scale & size */
662+ if (getc(mpeg->stream) < 0)
663+ return -1;
664+ c = getc(mpeg->stream);
665+ if (c < 0)
666+ return -1;
667+ }
668+ if ((c & 0xf0) == 0x20) { /* System-1 stream timestamp */
669+ /* Do we need this? */
670+ abort();
671+ }
672+ else if ((c & 0xf0) == 0x30) {
673+ /* Do we need this? */
674+ abort();
675+ }
676+ else if ((c & 0xc0) == 0x80) { /* System-2 (.VOB) stream */
677+ unsigned int pts_flags, hdrlen, dataidx;
678+ c = getc(mpeg->stream);
679+ if (c < 0)
680+ return -1;
681+ pts_flags = c;
682+ c = getc(mpeg->stream);
683+ if (c < 0)
684+ return -1;
685+ hdrlen = c;
686+ dataidx = mpeg_tell(mpeg) + hdrlen;
687+ if (dataidx > idx + len) {
688+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Invalid header length: %d (total length: %d, idx: %d, dataidx: %d)\n",
689+ hdrlen, len, idx, dataidx);
690+ return -1;
691+ }
692+ if ((pts_flags & 0xc0) == 0x80) {
693+ if (fread(buf, 5, 1, mpeg->stream) != 1)
694+ return -1;
695+ if (!(((buf[0] & 0xf0) == 0x20) && (buf[0] & 1) && (buf[2] & 1) && (buf[4] & 1))) {
696+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "vobsub PTS error: 0x%02x %02x%02x %02x%02x \n",
697+ buf[0], buf[1], buf[2], buf[3], buf[4]);
698+ mpeg->pts = 0;
699+ }
700+ else
701+ mpeg->pts = ((buf[0] & 0x0e) << 29 | buf[1] << 22 | (buf[2] & 0xfe) << 14
702+ | buf[3] << 7 | (buf[4] >> 1));
703+ }
704+ else /* if ((pts_flags & 0xc0) == 0xc0) */ {
705+ /* what's this? */
706+ /* abort(); */
707+ }
708+ fseek(mpeg->stream, dataidx, SEEK_SET);
709+ mpeg->aid = getc(mpeg->stream);
710+ if (mpeg->aid < 0) {
711+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Bogus aid %d\n", mpeg->aid);
712+ return -1;
713+ }
714+ mpeg->packet_size = len - ((unsigned int) mpeg_tell(mpeg) - idx);
715+ if (mpeg->packet_reserve < mpeg->packet_size) {
716+ if (mpeg->packet)
717+ free(mpeg->packet);
718+ mpeg->packet = malloc(mpeg->packet_size);
719+ if (mpeg->packet)
720+ mpeg->packet_reserve = mpeg->packet_size;
721+ }
722+ if (mpeg->packet == NULL) {
723+ mp_msg(MSGT_VOBSUB,MSGL_FATAL,"malloc failure");
724+ mpeg->packet_reserve = 0;
725+ mpeg->packet_size = 0;
726+ return -1;
727+ }
728+ if (fread(mpeg->packet, mpeg->packet_size, 1, mpeg->stream) != 1) {
729+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"fread failure");
730+ mpeg->packet_size = 0;
731+ return -1;
732+ }
733+ idx = len;
734+ }
735+ break;
736+ case 0xbe: /* Padding */
737+ if (fread(buf, 2, 1, mpeg->stream) != 1)
738+ return -1;
739+ len = buf[0] << 8 | buf[1];
740+ if (len > 0 && fseek(mpeg->stream, len, SEEK_CUR))
741+ return -1;
742+ break;
743+ default:
744+ if (0xc0 <= buf[3] && buf[3] < 0xf0) {
745+ /* MPEG audio or video */
746+ if (fread(buf, 2, 1, mpeg->stream) != 1)
747+ return -1;
748+ len = buf[0] << 8 | buf[1];
749+ if (len > 0 && fseek(mpeg->stream, len, SEEK_CUR))
750+ return -1;
751+
752+ }
753+ else {
754+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"unknown header 0x%02X%02X%02X%02X\n",
755+ buf[0], buf[1], buf[2], buf[3]);
756+ return -1;
757+ }
758+ }
759+ return 0;
760+}
761+
762+/**********************************************************************
763+ * Packet queue
764+ **********************************************************************/
765+
766+typedef struct {
767+ unsigned int pts100;
768+ off_t filepos;
769+ unsigned int size;
770+ unsigned char *data;
771+} packet_t;
772+
773+typedef struct {
774+ char *id;
775+ packet_t *packets;
776+ unsigned int packets_reserve;
777+ unsigned int packets_size;
778+ unsigned int current_index;
779+} packet_queue_t;
780+
781+static void
782+packet_construct(packet_t *pkt)
783+{
784+ pkt->pts100 = 0;
785+ pkt->filepos = 0;
786+ pkt->size = 0;
787+ pkt->data = NULL;
788+}
789+
790+static void
791+packet_destroy(packet_t *pkt)
792+{
793+ if (pkt->data)
794+ free(pkt->data);
795+}
796+
797+static void
798+packet_queue_construct(packet_queue_t *queue)
799+{
800+ queue->id = NULL;
801+ queue->packets = NULL;
802+ queue->packets_reserve = 0;
803+ queue->packets_size = 0;
804+ queue->current_index = 0;
805+}
806+
807+static void
808+packet_queue_destroy(packet_queue_t *queue)
809+{
810+ if (queue->packets) {
811+ while (queue->packets_size--)
812+ packet_destroy(queue->packets + queue->packets_size);
813+ free(queue->packets);
814+ }
815+ return;
816+}
817+
818+/* Make sure there is enough room for needed_size packets in the
819+ packet queue. */
820+static int
821+packet_queue_ensure(packet_queue_t *queue, unsigned int needed_size)
822+{
823+ if (queue->packets_reserve < needed_size) {
824+ if (queue->packets) {
825+ packet_t *tmp = realloc(queue->packets, 2 * queue->packets_reserve * sizeof(packet_t));
826+ if (tmp == NULL) {
827+ mp_msg(MSGT_VOBSUB,MSGL_FATAL,"realloc failure");
828+ return -1;
829+ }
830+ queue->packets = tmp;
831+ queue->packets_reserve *= 2;
832+ }
833+ else {
834+ queue->packets = malloc(sizeof(packet_t));
835+ if (queue->packets == NULL) {
836+ mp_msg(MSGT_VOBSUB,MSGL_FATAL,"malloc failure");
837+ return -1;
838+ }
839+ queue->packets_reserve = 1;
840+ }
841+ }
842+ return 0;
843+}
844+
845+/* add one more packet */
846+static int
847+packet_queue_grow(packet_queue_t *queue)
848+{
849+ if (packet_queue_ensure(queue, queue->packets_size + 1) < 0)
850+ return -1;
851+ packet_construct(queue->packets + queue->packets_size);
852+ ++queue->packets_size;
853+ return 0;
854+}
855+
856+/* insert a new packet, duplicating pts from the current one */
857+static int
858+packet_queue_insert(packet_queue_t *queue)
859+{
860+ packet_t *pkts;
861+ if (packet_queue_ensure(queue, queue->packets_size + 1) < 0)
862+ return -1;
863+ /* XXX packet_size does not reflect the real thing here, it will be updated a bit later */
864+ memmove(queue->packets + queue->current_index + 2,
865+ queue->packets + queue->current_index + 1,
866+ sizeof(packet_t) * (queue->packets_size - queue->current_index - 1));
867+ pkts = queue->packets + queue->current_index;
868+ ++queue->packets_size;
869+ ++queue->current_index;
870+ packet_construct(pkts + 1);
871+ pkts[1].pts100 = pkts[0].pts100;
872+ pkts[1].filepos = pkts[0].filepos;
873+ return 0;
874+}
875+
876+/**********************************************************************
877+ * Vobsub
878+ **********************************************************************/
879+
880+typedef struct {
881+ unsigned int palette[16];
882+ unsigned int cuspal[4];
883+ int delay;
884+ unsigned int custom;
885+ unsigned int have_palette;
886+ unsigned int orig_frame_width, orig_frame_height;
887+ unsigned int origin_x, origin_y;
888+ /* index */
889+ packet_queue_t *spu_streams;
890+ unsigned int spu_streams_size;
891+ unsigned int spu_streams_current;
892+} vobsub_t;
893+
894+/* Make sure that the spu stream idx exists. */
895+static int
896+vobsub_ensure_spu_stream(vobsub_t *vob, unsigned int index)
897+{
898+ if (index >= vob->spu_streams_size) {
899+ /* This is a new stream */
900+ if (vob->spu_streams) {
901+ packet_queue_t *tmp = realloc(vob->spu_streams, (index + 1) * sizeof(packet_queue_t));
902+ if (tmp == NULL) {
903+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"vobsub_ensure_spu_stream: realloc failure");
904+ return -1;
905+ }
906+ vob->spu_streams = tmp;
907+ }
908+ else {
909+ vob->spu_streams = malloc((index + 1) * sizeof(packet_queue_t));
910+ if (vob->spu_streams == NULL) {
911+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"vobsub_ensure_spu_stream: malloc failure");
912+ return -1;
913+ }
914+ }
915+ while (vob->spu_streams_size <= index) {
916+ packet_queue_construct(vob->spu_streams + vob->spu_streams_size);
917+ ++vob->spu_streams_size;
918+ }
919+ }
920+ return 0;
921+}
922+
923+static int
924+vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int index)
925+{
926+ if (vobsub_ensure_spu_stream(vob, index) < 0)
927+ return -1;
928+ if (id && idlen) {
929+ if (vob->spu_streams[index].id)
930+ free(vob->spu_streams[index].id);
931+ vob->spu_streams[index].id = malloc(idlen + 1);
932+ if (vob->spu_streams[index].id == NULL) {
933+ mp_msg(MSGT_VOBSUB,MSGL_FATAL,"vobsub_add_id: malloc failure");
934+ return -1;
935+ }
936+ vob->spu_streams[index].id[idlen] = 0;
937+ memcpy(vob->spu_streams[index].id, id, idlen);
938+ }
939+ vob->spu_streams_current = index;
940+ if (verbose)
941+ mp_msg(MSGT_VOBSUB,MSGL_V,"[vobsub] subtitle (vobsubid): %d language %s\n",
942+ index, vob->spu_streams[index].id);
943+ return 0;
944+}
945+
946+static int
947+vobsub_add_timestamp(vobsub_t *vob, off_t filepos, unsigned int ms)
948+{
949+ packet_queue_t *queue;
950+ packet_t *pkt;
951+ if (vob->spu_streams == 0) {
952+ mp_msg(MSGT_VOBSUB,MSGL_WARN,"[vobsub] warning, binning some index entries. Check your index file\n");
953+ return -1;
954+ }
955+ queue = vob->spu_streams + vob->spu_streams_current;
956+ if (packet_queue_grow(queue) >= 0) {
957+ pkt = queue->packets + (queue->packets_size - 1);
958+ pkt->filepos = filepos;
959+ pkt->pts100 = ms * 90;
960+ return 0;
961+ }
962+ return -1;
963+}
964+
965+static int
966+vobsub_parse_id(vobsub_t *vob, const char *line)
967+{
968+ // id: xx, index: n
969+ size_t idlen;
970+ const char *p, *q;
971+ p = line;
972+ while (isspace(*p))
973+ ++p;
974+ q = p;
975+ while (isalpha(*q))
976+ ++q;
977+ idlen = q - p;
978+ if (idlen == 0)
979+ return -1;
980+ ++q;
981+ while (isspace(*q))
982+ ++q;
983+ if (strncmp("index:", q, 6))
984+ return -1;
985+ q += 6;
986+ while (isspace(*q))
987+ ++q;
988+ if (!isdigit(*q))
989+ return -1;
990+ return vobsub_add_id(vob, p, idlen, atoi(q));
991+}
992+
993+static int
994+vobsub_parse_timestamp(vobsub_t *vob, const char *line)
995+{
996+ // timestamp: HH:MM:SS.mmm, filepos: 0nnnnnnnnn
997+ const char *p;
998+ int h, m, s, ms;
999+ off_t filepos;
1000+ while (isspace(*line))
1001+ ++line;
1002+ p = line;
1003+ while (isdigit(*p))
1004+ ++p;
1005+ if (p - line != 2)
1006+ return -1;
1007+ h = atoi(line);
1008+ if (*p != ':')
1009+ return -1;
1010+ line = ++p;
1011+ while (isdigit(*p))
1012+ ++p;
1013+ if (p - line != 2)
1014+ return -1;
1015+ m = atoi(line);
1016+ if (*p != ':')
1017+ return -1;
1018+ line = ++p;
1019+ while (isdigit(*p))
1020+ ++p;
1021+ if (p - line != 2)
1022+ return -1;
1023+ s = atoi(line);
1024+ if (*p != ':')
1025+ return -1;
1026+ line = ++p;
1027+ while (isdigit(*p))
1028+ ++p;
1029+ if (p - line != 3)
1030+ return -1;
1031+ ms = atoi(line);
1032+ if (*p != ',')
1033+ return -1;
1034+ line = p + 1;
1035+ while (isspace(*line))
1036+ ++line;
1037+ if (strncmp("filepos:", line, 8))
1038+ return -1;
1039+ line += 8;
1040+ while (isspace(*line))
1041+ ++line;
1042+ if (! isxdigit(*line))
1043+ return -1;
1044+ filepos = strtol(line, NULL, 16);
1045+ return vobsub_add_timestamp(vob, filepos, vob->delay + ms + 1000 * (s + 60 * (m + 60 * h)));
1046+}
1047+
1048+static int
1049+vobsub_parse_size(vobsub_t *vob, const char *line)
1050+{
1051+ // size: WWWxHHH
1052+ char *p;
1053+ while (isspace(*line))
1054+ ++line;
1055+ if (!isdigit(*line))
1056+ return -1;
1057+ vob->orig_frame_width = strtoul(line, &p, 10);
1058+ if (*p != 'x')
1059+ return -1;
1060+ ++p;
1061+ vob->orig_frame_height = strtoul(p, NULL, 10);
1062+ return 0;
1063+}
1064+
1065+static int
1066+vobsub_parse_origin(vobsub_t *vob, const char *line)
1067+{
1068+ // org: X,Y
1069+ char *p;
1070+ while (isspace(*line))
1071+ ++line;
1072+ if (!isdigit(*line))
1073+ return -1;
1074+ vob->origin_x = strtoul(line, &p, 10);
1075+ if (*p != ',')
1076+ return -1;
1077+ ++p;
1078+ vob->origin_y = strtoul(p, NULL, 10);
1079+ return 0;
1080+}
1081+
1082+static int
1083+vobsub_parse_palette(vobsub_t *vob, const char *line)
1084+{
1085+ // palette: XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX
1086+ unsigned int n;
1087+ n = 0;
1088+ while (1) {
1089+ const char *p;
1090+ int r, g, b, y, u, v, tmp;
1091+ while (isspace(*line))
1092+ ++line;
1093+ p = line;
1094+ while (isxdigit(*p))
1095+ ++p;
1096+ if (p - line != 6)
1097+ return -1;
1098+ tmp = strtoul(line, NULL, 16);
1099+ r = tmp >> 16 & 0xff;
1100+ g = tmp >> 8 & 0xff;
1101+ b = tmp & 0xff;
1102+ y = MIN(MAX((int)(0.1494 * r + 0.6061 * g + 0.2445 * b), 0), 0xff);
1103+ u = MIN(MAX((int)(0.6066 * r - 0.4322 * g - 0.1744 * b) + 128, 0), 0xff);
1104+ v = MIN(MAX((int)(-0.08435 * r - 0.3422 * g + 0.4266 * b) + 128, 0), 0xff);
1105+ vob->palette[n++] = y << 16 | u << 8 | v;
1106+ if (n == 16)
1107+ break;
1108+ if (*p == ',')
1109+ ++p;
1110+ line = p;
1111+ }
1112+ vob->have_palette = 1;
1113+ return 0;
1114+}
1115+
1116+static int
1117+vobsub_parse_custom(vobsub_t *vob, const char *line)
1118+{
1119+ //custom colors: OFF/ON(0/1)
1120+ if ((strncmp("ON", line + 15, 2) == 0)||strncmp("1", line + 15, 1) == 0)
1121+ vob->custom=1;
1122+ else if ((strncmp("OFF", line + 15, 3) == 0)||strncmp("0", line + 15, 1) == 0)
1123+ vob->custom=0;
1124+ else
1125+ return -1;
1126+ return 0;
1127+}
1128+
1129+static int
1130+vobsub_parse_cuspal(vobsub_t *vob, const char *line)
1131+{
1132+ //colors: XXXXXX, XXXXXX, XXXXXX, XXXXXX
1133+ unsigned int n;
1134+ n = 0;
1135+ line += 40;
1136+ while(1){
1137+ const char *p;
1138+ while (isspace(*line))
1139+ ++line;
1140+ p=line;
1141+ while (isxdigit(*p))
1142+ ++p;
1143+ if (p - line !=6)
1144+ return -1;
1145+ vob->cuspal[n++] = strtoul(line, NULL,16);
1146+ if (n==4)
1147+ break;
1148+ if(*p == ',')
1149+ ++p;
1150+ line = p;
1151+ }
1152+ return 0;
1153+}
1154+
1155+/* don't know how to use tridx */
1156+static int
1157+vobsub_parse_tridx(const char *line)
1158+{
1159+ //tridx: XXXX
1160+ int tridx;
1161+ tridx = strtoul((line + 26), NULL, 16);
1162+ tridx = ((tridx&0x1000)>>12) | ((tridx&0x100)>>7) | ((tridx&0x10)>>2) | ((tridx&1)<<3);
1163+ return tridx;
1164+}
1165+
1166+static int
1167+vobsub_parse_delay(vobsub_t *vob, const char *line)
1168+{
1169+ int h, m, s, ms;
1170+ int forward = 1;
1171+ if (*(line + 7) == '+'){
1172+ forward = 1;
1173+ line++;
1174+ }
1175+ else if (*(line + 7) == '-'){
1176+ forward = -1;
1177+ line++;
1178+ }
1179+ mp_msg(MSGT_SPUDEC,MSGL_V, "forward=%d", forward);
1180+ h = atoi(line + 7);
1181+ mp_msg(MSGT_VOBSUB,MSGL_V, "h=%d," ,h);
1182+ m = atoi(line + 10);
1183+ mp_msg(MSGT_VOBSUB,MSGL_V, "m=%d,", m);
1184+ s = atoi(line + 13);
1185+ mp_msg(MSGT_VOBSUB,MSGL_V, "s=%d,", s);
1186+ ms = atoi(line + 16);
1187+ mp_msg(MSGT_VOBSUB,MSGL_V, "ms=%d", ms);
1188+ vob->delay = ms + 1000 * (s + 60 * (m + 60 * h)) * forward;
1189+ return 0;
1190+}
1191+
1192+static int
1193+vobsub_set_lang(const char *line)
1194+{
1195+ if (vobsub_id == -1)
1196+ vobsub_id = atoi(line + 8);
1197+ return 0;
1198+}
1199+
1200+static int
1201+vobsub_parse_one_line(vobsub_t *vob, FILE *fd)
1202+{
1203+ ssize_t line_size;
1204+ int res = -1;
1205+ do {
1206+ size_t line_reserve = 0;
1207+ char *line = NULL;
1208+ line_size = getline(&line, &line_reserve, fd);
1209+ if (line_size < 0) {
1210+ if (line)
1211+ free(line);
1212+ break;
1213+ }
1214+ if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#')
1215+ continue;
1216+ else if (strncmp("langidx:", line, 8) == 0)
1217+ res = vobsub_set_lang(line);
1218+ else if (strncmp("delay:", line, 6) == 0)
1219+ res = vobsub_parse_delay(vob, line);
1220+ else if (strncmp("id:", line, 3) == 0)
1221+ res = vobsub_parse_id(vob, line + 3);
1222+ else if (strncmp("palette:", line, 8) == 0)
1223+ res = vobsub_parse_palette(vob, line + 8);
1224+ else if (strncmp("size:", line, 5) == 0)
1225+ res = vobsub_parse_size(vob, line + 5);
1226+ else if (strncmp("org:", line, 4) == 0)
1227+ res = vobsub_parse_origin(vob, line + 4);
1228+ else if (strncmp("timestamp:", line, 10) == 0)
1229+ res = vobsub_parse_timestamp(vob, line + 10);
1230+ else if (strncmp("custom colors:", line, 14) == 0)
1231+ //custom colors: ON/OFF, tridx: XXXX, colors: XXXXXX, XXXXXX, XXXXXX,XXXXXX
1232+ res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(line) + vobsub_parse_custom(vob, line);
1233+ else {
1234+ if (verbose)
1235+ mp_msg(MSGT_VOBSUB,MSGL_V, "vobsub: ignoring %s", line);
1236+ continue;
1237+ }
1238+ if (res < 0)
1239+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "ERROR in %s", line);
1240+ break;
1241+ } while (1);
1242+ return res;
1243+}
1244+
1245+int
1246+vobsub_parse_ifo(void* this, const char *const name, unsigned int *palette, unsigned int *width, unsigned int *height, int force,
1247+ int sid, char *langid)
1248+{
1249+ vobsub_t *vob = (vobsub_t*)this;
1250+ int res = -1;
1251+ FILE *fd = fopen(name, "rb");
1252+ if (fd == NULL) {
1253+ if (force)
1254+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't open IFO file");
1255+ } else {
1256+ // parse IFO header
1257+ unsigned char block[0x800];
1258+ const char *const ifo_magic = "DVDVIDEO-VTS";
1259+ if (fread(block, sizeof(block), 1, fd) != 1) {
1260+ if (force)
1261+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't read IFO header");
1262+ } else if (memcmp(block, ifo_magic, strlen(ifo_magic) + 1))
1263+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Bad magic in IFO header\n");
1264+ else {
1265+ unsigned long pgci_sector = block[0xcc] << 24 | block[0xcd] << 16
1266+ | block[0xce] << 8 | block[0xcf];
1267+ int standard = (block[0x200] & 0x30) >> 4;
1268+ int resolution = (block[0x201] & 0x0c) >> 2;
1269+ *height = standard ? 576 : 480;
1270+ *width = 0;
1271+ switch (resolution) {
1272+ case 0x0:
1273+ *width = 720;
1274+ break;
1275+ case 0x1:
1276+ *width = 704;
1277+ break;
1278+ case 0x2:
1279+ *width = 352;
1280+ break;
1281+ case 0x3:
1282+ *width = 352;
1283+ *height /= 2;
1284+ break;
1285+ default:
1286+ mp_msg(MSGT_VOBSUB,MSGL_WARN,"Vobsub: Unknown resolution %d \n", resolution);
1287+ }
1288+ if (langid && 0 <= sid && sid < 32) {
1289+ unsigned char *tmp = block + 0x256 + sid * 6 + 2;
1290+ langid[0] = tmp[0];
1291+ langid[1] = tmp[1];
1292+ langid[2] = 0;
1293+ }
1294+ if (fseek(fd, pgci_sector * sizeof(block), SEEK_SET)
1295+ || fread(block, sizeof(block), 1, fd) != 1)
1296+ mp_msg(MSGT_VOBSUB,MSGL_ERR, "Can't read IFO PGCI");
1297+ else {
1298+ unsigned long idx;
1299+ unsigned long pgc_offset = block[0xc] << 24 | block[0xd] << 16
1300+ | block[0xe] << 8 | block[0xf];
1301+ for (idx = 0; idx < 16; ++idx) {
1302+ unsigned char *p = block + pgc_offset + 0xa4 + 4 * idx;
1303+ palette[idx] = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
1304+ }
1305+ if(vob)
1306+ vob->have_palette = 1;
1307+ res = 0;
1308+ }
1309+ }
1310+ fclose(fd);
1311+ }
1312+ return res;
1313+}
1314+
1315+void *
1316+vobsub_open(const char *const name,const char *const ifo,const int force,void** spu)
1317+{
1318+ vobsub_t *vob = malloc(sizeof(vobsub_t));
1319+ if(spu)
1320+ *spu = NULL;
1321+ if (vob) {
1322+ char *buf;
1323+ vob->custom = 0;
1324+ vob->have_palette = 0;
1325+ vob->orig_frame_width = 0;
1326+ vob->orig_frame_height = 0;
1327+ vob->spu_streams = NULL;
1328+ vob->spu_streams_size = 0;
1329+ vob->spu_streams_current = 0;
1330+ vob->delay = 0;
1331+ buf = malloc((strlen(name) + 5) * sizeof(char));
1332+ if (buf) {
1333+ FILE *fd;
1334+ mpeg_t *mpg;
1335+ /* read in the info file */
1336+ if(!ifo) {
1337+ strcpy(buf, name);
1338+ strcat(buf, ".ifo");
1339+ vobsub_parse_ifo(vob,buf, vob->palette, &vob->orig_frame_width, &vob->orig_frame_height, force, -1, NULL);
1340+ } else
1341+ vobsub_parse_ifo(vob,ifo, vob->palette, &vob->orig_frame_width, &vob->orig_frame_height, force, -1, NULL);
1342+ /* read in the index */
1343+ strcpy(buf, name);
1344+ strcat(buf, ".idx");
1345+ fd = fopen(buf, "rb");
1346+ if (fd == NULL) {
1347+ if(force)
1348+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"VobSub: Can't open IDX file");
1349+ else {
1350+ free(buf);
1351+ free(vob);
1352+ return NULL;
1353+ }
1354+ } else {
1355+ while (vobsub_parse_one_line(vob, fd) >= 0)
1356+ /* NOOP */ ;
1357+ fclose(fd);
1358+ }
1359+ /* if no palette in .idx then use custom colors */
1360+ if ((vob->custom == 0)&&(vob->have_palette!=1))
1361+ vob->custom = 1;
1362+
1363+ if (spu && vob->orig_frame_width && vob->orig_frame_height)
1364+ *spu = spudec_new_scaled_vobsub(vob->palette, vob->cuspal, vob->custom, vob->orig_frame_width, vob->orig_frame_height);
1365+ /* read the indexed mpeg_stream */
1366+ strcpy(buf, name);
1367+ strcat(buf, ".sub");
1368+ mpg = mpeg_open(buf);
1369+ if (mpg == NULL) {
1370+ if(force)
1371+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"VobSub: Can't open SUB file");
1372+ else {
1373+
1374+ free(buf);
1375+ free(vob);
1376+ return NULL;
1377+ }
1378+ } else {
1379+ long last_pts_diff = 0;
1380+ while (!mpeg_eof(mpg)) {
1381+ off_t pos = mpeg_tell(mpg);
1382+ if (mpeg_run(mpg) < 0) {
1383+ if (!mpeg_eof(mpg))
1384+ mp_msg(MSGT_VOBSUB,MSGL_ERR,"mpeg_run error");
1385+ break;
1386+ }
1387+ if (mpg->packet_size) {
1388+ if ((mpg->aid & 0xe0) == 0x20) {
1389+ unsigned int sid = mpg->aid & 0x1f;
1390+ if (vobsub_ensure_spu_stream(vob, sid) >= 0) {
1391+ packet_queue_t *queue = vob->spu_streams + sid;
1392+ /* get the packet to fill */
1393+ if (queue->packets_size == 0 && packet_queue_grow(queue) < 0)
1394+ abort();
1395+ while (queue->current_index + 1 < queue->packets_size
1396+ && queue->packets[queue->current_index + 1].filepos <= pos)
1397+ ++queue->current_index;
1398+ if (queue->current_index < queue->packets_size) {
1399+ packet_t *pkt;
1400+ if (queue->packets[queue->current_index].data) {
1401+ /* insert a new packet and fix the PTS ! */
1402+ packet_queue_insert(queue);
1403+ queue->packets[queue->current_index].pts100 =
1404+ mpg->pts + last_pts_diff;
1405+ }
1406+ pkt = queue->packets + queue->current_index;
1407+ if (queue->packets_size > 1)
1408+ last_pts_diff = pkt->pts100 - mpg->pts;
1409+ else
1410+ pkt->pts100 = mpg->pts;
1411+ /* FIXME: should not use mpg_sub internal informations, make a copy */
1412+ pkt->data = mpg->packet;
1413+ pkt->size = mpg->packet_size;
1414+ mpg->packet = NULL;
1415+ mpg->packet_reserve = 0;
1416+ mpg->packet_size = 0;
1417+ }
1418+ }
1419+ else
1420+ mp_msg(MSGT_VOBSUB,MSGL_WARN, "don't know what to do with subtitle #%u\n", sid);
1421+ }
1422+ }
1423+ }
1424+ vob->spu_streams_current = vob->spu_streams_size;
1425+ while (vob->spu_streams_current-- > 0)
1426+ vob->spu_streams[vob->spu_streams_current].current_index = 0;
1427+ mpeg_free(mpg);
1428+ }
1429+ free(buf);
1430+ }
1431+ }
1432+ return vob;
1433+}
1434+
1435+void
1436+vobsub_close(void *this)
1437+{
1438+ vobsub_t *vob = (vobsub_t *)this;
1439+ if (vob->spu_streams) {
1440+ while (vob->spu_streams_size--)
1441+ packet_queue_destroy(vob->spu_streams + vob->spu_streams_size);
1442+ free(vob->spu_streams);
1443+ }
1444+ free(vob);
1445+}
1446+
1447+int
1448+vobsub_get_packet(void *vobhandle, float pts,void** data, int* timestamp) {
1449+ vobsub_t *vob = (vobsub_t *)vobhandle;
1450+ unsigned int pts100 = 90000 * pts;
1451+ if (vob->spu_streams && 0 <= vobsub_id && (unsigned) vobsub_id < vob->spu_streams_size) {
1452+ packet_queue_t *queue = vob->spu_streams + vobsub_id;
1453+ while (queue->current_index < queue->packets_size) {
1454+ packet_t *pkt = queue->packets + queue->current_index;
1455+ if (pkt->pts100 <= pts100) {
1456+ ++queue->current_index;
1457+ *data = pkt->data;
1458+ *timestamp = pkt->pts100;
1459+ return pkt->size;
1460+ } else break;
1461+ }
1462+ }
1463+ return -1;
1464+}
1465+
1466+int
1467+vobsub_get_next_packet(void *vobhandle, void** data, int* timestamp)
1468+{
1469+ vobsub_t *vob = (vobsub_t *)vobhandle;
1470+ if (vob->spu_streams && 0 <= vobsub_id && (unsigned) vobsub_id < vob->spu_streams_size) {
1471+ packet_queue_t *queue = vob->spu_streams + vobsub_id;
1472+ if (queue->current_index < queue->packets_size) {
1473+ packet_t *pkt = queue->packets + queue->current_index;
1474+ ++queue->current_index;
1475+ *data = pkt->data;
1476+ *timestamp = pkt->pts100;
1477+ return pkt->size;
1478+ }
1479+ }
1480+ return -1;
1481+}
1482+
1483+void
1484+vobsub_reset(void *vobhandle)
1485+{
1486+ vobsub_t *vob = (vobsub_t *)vobhandle;
1487+ if (vob->spu_streams) {
1488+ unsigned int n = vob->spu_streams_size;
1489+ while (n-- > 0)
1490+ vob->spu_streams[n].current_index = 0;
1491+ }
1492+}
1493+
1494+/**********************************************************************
1495+ * Vobsub output
1496+ **********************************************************************/
1497+
1498+typedef struct {
1499+ FILE *fsub;
1500+ FILE *fidx;
1501+ unsigned int aid;
1502+} vobsub_out_t;
1503+
1504+static void
1505+create_idx(vobsub_out_t *me, const unsigned int *palette, unsigned int orig_width, unsigned int orig_height)
1506+{
1507+ int i;
1508+ fprintf(me->fidx,
1509+ "# VobSub index file, v7 (do not modify this line!)\n"
1510+ "#\n"
1511+ "# Generated by MPlayer " VERSION "\n"
1512+ "# See <URL:http://www.mplayerhq.hu/> for more information about MPlayer\n"
1513+ "# See <URL:http://vobsub.edensrising.com/> for more information about Vobsub\n"
1514+ "#\n"
1515+ "size: %ux%u\n",
1516+ orig_width, orig_height);
1517+ if (palette) {
1518+ fputs("palette:", me->fidx);
1519+ for (i = 0; i < 16; ++i) {
1520+ const double y = palette[i] >> 16 & 0xff,
1521+ u = (palette[i] >> 8 & 0xff) - 128.0,
1522+ v = (palette[i] & 0xff) - 128.0;
1523+ if (i)
1524+ putc(',', me->fidx);
1525+ fprintf(me->fidx, " %02x%02x%02x",
1526+ MIN(MAX((int)(y + 1.4022 * u), 0), 0xff),
1527+ MIN(MAX((int)(y - 0.3456 * u - 0.7145 * v), 0), 0xff),
1528+ MIN(MAX((int)(y + 1.7710 * v), 0), 0xff));
1529+ }
1530+ putc('\n', me->fidx);
1531+ }
1532+}
1533+
1534+void *
1535+vobsub_out_open(const char *basename, const unsigned int *palette,
1536+ unsigned int orig_width, unsigned int orig_height,
1537+ const char *id, unsigned int index)
1538+{
1539+ vobsub_out_t *result = NULL;
1540+ char *filename;
1541+ filename = malloc(strlen(basename) + 5);
1542+ if (filename) {
1543+ result = malloc(sizeof(vobsub_out_t));
1544+ result->fsub = NULL;
1545+ result->fidx = NULL;
1546+ result->aid = 0;
1547+ if (result) {
1548+ result->aid = index;
1549+ strcpy(filename, basename);
1550+ strcat(filename, ".sub");
1551+ result->fsub = fopen(filename, "a");
1552+ if (result->fsub == NULL)
1553+ perror("Error: vobsub_out_open subtitle file open failed");
1554+ strcpy(filename, basename);
1555+ strcat(filename, ".idx");
1556+ result->fidx = fopen(filename, "a");
1557+ if (result->fidx) {
1558+ if (ftell(result->fidx) == 0){
1559+ create_idx(result, palette, orig_width, orig_height);
1560+
1561+ /* Make the selected language the default language */
1562+ fprintf(result->fidx, "\n# Language index in use\nlangidx: %u\n", index);
1563+ }
1564+
1565+ fprintf(result->fidx, "\nid: %s, index: %u\n", id ? id : "xx", index);
1566+
1567+ /* So that we can check the file now */
1568+ fflush(result->fidx);
1569+ }
1570+ else
1571+ perror("Error: vobsub_out_open index file open failed");
1572+ free(filename);
1573+ }
1574+ }
1575+ return result;
1576+}
1577+
1578+void
1579+vobsub_out_close(void *me)
1580+{
1581+ vobsub_out_t *vob = (vobsub_out_t*)me;
1582+ if (vob->fidx)
1583+ fclose(vob->fidx);
1584+ if (vob->fsub)
1585+ fclose(vob->fsub);
1586+ free(vob);
1587+}
1588+
1589+void
1590+vobsub_out_output(void *me, const unsigned char *packet, int len, double pts)
1591+{
1592+ static double last_pts;
1593+ static int last_pts_set = 0;
1594+ vobsub_out_t *vob = (vobsub_out_t*)me;
1595+ if (vob->fsub) {
1596+ /* Windows' Vobsub require that every packet is exactly 2kB long */
1597+ unsigned char buffer[2048];
1598+ unsigned char *p;
1599+ int remain = 2048;
1600+ /* Do not output twice a line with the same timestamp, this
1601+ breaks Windows' Vobsub */
1602+ if (vob->fidx && (!last_pts_set || last_pts != pts)) {
1603+ static unsigned int last_h = 9999, last_m = 9999, last_s = 9999, last_ms = 9999;
1604+ unsigned int h, m, ms;
1605+ double s;
1606+ s = pts;
1607+ h = s / 3600;
1608+ s -= h * 3600;
1609+ m = s / 60;
1610+ s -= m * 60;
1611+ ms = (s - (unsigned int) s) * 1000;
1612+ if (ms >= 1000) /* prevent overfolws or bad float stuff */
1613+ ms = 0;
1614+ if (h != last_h || m != last_m || (unsigned int) s != last_s || ms != last_ms) {
1615+ fprintf(vob->fidx, "timestamp: %02u:%02u:%02u:%03u, filepos: %09lx\n",
1616+ h, m, (unsigned int) s, ms, ftell(vob->fsub));
1617+ last_h = h;
1618+ last_m = m;
1619+ last_s = (unsigned int) s;
1620+ last_ms = ms;
1621+ }
1622+ }
1623+ last_pts = pts;
1624+ last_pts_set = 1;
1625+
1626+ /* Packet start code: Windows' Vobsub needs this */
1627+ p = buffer;
1628+ *p++ = 0; /* 0x00 */
1629+ *p++ = 0;
1630+ *p++ = 1;
1631+ *p++ = 0xba;
1632+ *p++ = 0x40;
1633+ memset(p, 0, 9);
1634+ p += 9;
1635+ { /* Packet */
1636+ static unsigned char last_pts[5] = { 0, 0, 0, 0, 0};
1637+ unsigned char now_pts[5];
1638+ int pts_len, pad_len, datalen = len;
1639+ pts *= 90000;
1640+ now_pts[0] = 0x21 | (((unsigned long)pts >> 29) & 0x0e);
1641+ now_pts[1] = ((unsigned long)pts >> 22) & 0xff;
1642+ now_pts[2] = 0x01 | (((unsigned long)pts >> 14) & 0xfe);
1643+ now_pts[3] = ((unsigned long)pts >> 7) & 0xff;
1644+ now_pts[4] = 0x01 | (((unsigned long)pts << 1) & 0xfe);
1645+ pts_len = memcmp(last_pts, now_pts, sizeof(now_pts)) ? sizeof(now_pts) : 0;
1646+ memcpy(last_pts, now_pts, sizeof(now_pts));
1647+
1648+ datalen += 3; /* Version, PTS_flags, pts_len */
1649+ datalen += pts_len;
1650+ datalen += 1; /* AID */
1651+ pad_len = 2048 - (p - buffer) - 4 /* MPEG ID */ - 2 /* payload len */ - datalen;
1652+ /* XXX - Go figure what should go here! In any case the
1653+ packet has to be completly filled. If I can fill it
1654+ with padding (0x000001be) latter I'll do that. But if
1655+ there is only room for 6 bytes then I can not write a
1656+ padding packet. So I add some padding in the PTS
1657+ field. This looks like a dirty kludge. Oh well... */
1658+ if (pad_len < 0) {
1659+ /* Packet is too big. Let's try ommiting the PTS field */
1660+ datalen -= pts_len;
1661+ pts_len = 0;
1662+ pad_len = 0;
1663+ }
1664+ else if (pad_len > 6)
1665+ pad_len = 0;
1666+ datalen += pad_len;
1667+
1668+ *p++ = 0; /* 0x0e */
1669+ *p++ = 0;
1670+ *p++ = 1;
1671+ *p++ = 0xbd;
1672+
1673+ *p++ = (datalen >> 8) & 0xff; /* length of payload */
1674+ *p++ = datalen & 0xff;
1675+ *p++ = 0x80; /* System-2 (.VOB) stream */
1676+ *p++ = pts_len ? 0x80 : 0x00; /* pts_flags */
1677+ *p++ = pts_len + pad_len;
1678+ memcpy(p, now_pts, pts_len);
1679+ p += pts_len;
1680+ memset(p, 0, pad_len);
1681+ p += pad_len;
1682+ }
1683+ *p++ = 0x20 | vob->aid; /* aid */
1684+ if (fwrite(buffer, p - buffer, 1, vob->fsub) != 1
1685+ || fwrite(packet, len, 1, vob->fsub) != 1)
1686+ perror("ERROR: vobsub write failed");
1687+ else
1688+ remain -= p - buffer + len;
1689+
1690+ /* Padding */
1691+ if (remain >= 6) {
1692+ p = buffer;
1693+ *p++ = 0x00;
1694+ *p++ = 0x00;
1695+ *p++ = 0x01;
1696+ *p++ = 0xbe;
1697+ *p++ = (remain - 6) >> 8;
1698+ *p++ = (remain - 6) & 0xff;
1699+ /* for better compression, blank this */
1700+ memset(buffer + 6, 0, remain - (p - buffer));
1701+ if (fwrite(buffer, remain, 1, vob->fsub) != 1)
1702+ perror("ERROR: vobsub padding write failed");
1703+ }
1704+ else if (remain > 0) {
1705+ /* I don't know what to output. But anyway the block
1706+ needs to be 2KB big */
1707+ memset(buffer, 0, remain);
1708+ if (fwrite(buffer, remain, 1, vob->fsub) != 1)
1709+ perror("ERROR: vobsub blank padding write failed");
1710+ }
1711+ else if (remain < 0)
1712+ fprintf(stderr,
1713+ "\nERROR: wrong thing happenned...\n"
1714+ " I wrote a %i data bytes spu packet and that's too long\n", len);
1715+ }
1716+}
1717
1718=== added file '.pc/applied-patches'
1719--- .pc/applied-patches 1970-01-01 00:00:00 +0000
1720+++ .pc/applied-patches 2013-11-19 19:50:12 +0000
1721@@ -0,0 +1,4 @@
1722+03_getline.diff
1723+01_pgm2txt.patch
1724+02_Makefile.patch
1725+03_binutils-gold.patch
1726
1727=== modified file 'Makefile'
1728--- Makefile 2004-02-07 09:36:58 +0000
1729+++ Makefile 2013-11-19 19:50:12 +0000
1730@@ -9,7 +9,7 @@
1731
1732 ### enable ppm support ###
1733 DEFINES += -D_HAVE_LIB_PPM_
1734-LIBS += -lppm
1735+LIBS += -lnetpbm
1736
1737 ### enable PNG support ###
1738 DEFINES += -D_HAVE_PNG_
1739@@ -70,19 +70,19 @@
1740 # Target
1741 subtitle2pgm: subtitle2pgm.o spudec.o
1742 @echo "Linking $@"
1743- @$(CC) $(LIBS) $^ -o $@
1744+ @$(CC) $^ -o $@ $(LIBS)
1745
1746 subtitle2vobsub: subtitle2vobsub.o vobsub.o
1747 @echo "Linking $@"
1748- @$(CC) $(LIBS) $^ -o $@
1749+ @$(CC) $^ -o $@ $(LIBS)
1750
1751 srttool: srttool.o
1752 @echo "Linking $@"
1753- @$(CC) $(LIBS) -g $^ -o $@
1754+ @$(CC) -g $^ -o $@ $(LIBS)
1755
1756 vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
1757 @echo "Linking $@"
1758- @$(CC) $(LIBS) -g $^ -o $@
1759+ @$(CC) -g $^ -o $@ $(LIBS)
1760
1761 .PHONY: clean dist rpm
1762 clean:
1763
1764=== added file 'debian/README.source'
1765--- debian/README.source 1970-01-01 00:00:00 +0000
1766+++ debian/README.source 2013-11-19 19:50:12 +0000
1767@@ -0,0 +1,2 @@
1768+
1769+See /usr/share/doc/quilt/README.source
1770
1771=== modified file 'debian/changelog'
1772--- debian/changelog 2011-02-17 21:10:09 +0000
1773+++ debian/changelog 2013-11-19 19:50:12 +0000
1774@@ -1,3 +1,32 @@
1775+subtitleripper (0.3.4-dmo1ubuntu1) trusty; urgency=low
1776+
1777+ * Merge from deb-multimedia. Remaining changes:
1778+ - debian/patches/03_binutils-gold.dpatch: Fix FTBFS binutils-gold with
1779+ ld as-needed by adding LIBS after object.
1780+ - Add define HAVE_GETLINE in Makefile (modifying 02_Makefile) to
1781+ fix FTBFS.
1782+ * Fix typo with noticeable in changelog
1783+
1784+ -- Jackson Doak <noskcaj@ubuntu.com> Wed, 20 Nov 2013 06:13:57 +1100
1785+
1786+subtitleripper (0.3.4-dmo1) unstable; urgency=low
1787+
1788+ * Build with hardened flags.
1789+
1790+ -- Christian Marillat <marillat@deb-multimedia.org> Fri, 27 Jul 2012 15:11:13 +0200
1791+
1792+subtitleripper (0.3.4-0.7) unstable; urgency=low
1793+
1794+ * Use external getline.
1795+
1796+ -- Christian Marillat <marillat@debian.org> Thu, 11 Feb 2010 12:12:24 +0100
1797+
1798+subtitleripper (0.3.4-0.6) unstable; urgency=low
1799+
1800+ * Added subtitle2pgm manpage from A. Costa
1801+
1802+ -- Christian Marillat <marillat@debian.org> Sun, 07 Sep 2008 11:01:01 +0200
1803+
1804 subtitleripper (0.3.4-0.5ubuntu2) natty; urgency=low
1805
1806 * debian/patches/03_binutils-gold.dpatch: Fix FTBFS binutils-gold with
1807
1808=== modified file 'debian/compat'
1809--- debian/compat 2006-05-28 15:59:33 +0000
1810+++ debian/compat 2013-11-19 19:50:12 +0000
1811@@ -1,1 +1,1 @@
1812-4
1813+9
1814
1815=== modified file 'debian/control'
1816--- debian/control 2011-02-17 21:10:09 +0000
1817+++ debian/control 2013-11-19 19:50:12 +0000
1818@@ -1,15 +1,17 @@
1819 Source: subtitleripper
1820 Section: x11
1821 Priority: optional
1822-XSBC-Original-Maintainer: Christian Marillat <marillat@debian.org>
1823 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
1824-Bugs: mailto:marillat@debian.org
1825-Standards-Version: 3.7.2
1826-Build-Depends: debhelper (>> 4.0.0), libnetpbm10-dev, libpng12-dev | libpng-dev, dpatch
1827+XSBC-Original-Maintainer: Christian Marillat <marillat@deb-multimedia.org>
1828+Bugs: mailto:marillat@deb-multimedia.org
1829+Homepage: http://subtitleripper.sourceforge.net/
1830+Standards-Version: 3.9.3
1831+Build-Depends: debhelper (>= 9), libnetpbm10-dev, libpng-dev,
1832+ quilt
1833
1834 Package: subtitleripper
1835 Architecture: any
1836-Depends: ${shlibs:Depends}, gocr, transcode
1837+Depends: ${shlibs:Depends}, ${misc:Depends}, gocr, transcode
1838 Recommends: imagemagick
1839 Description: DVD Subtitle Ripper for Linux
1840 If you want to convert DVD subtitles into text format (e.g. subrip format)
1841
1842=== modified file 'debian/copyright'
1843--- debian/copyright 2006-05-28 15:59:33 +0000
1844+++ debian/copyright 2013-11-19 19:50:12 +0000
1845@@ -1,4 +1,4 @@
1846-This package was debianized by Christian Marillat <marillat@debian.org> on
1847+This package was debianized by Christian Marillat <marillat@deb-multimedia.org> on
1848 Sat, 23 Nov 2002 17:15:02 +0100.
1849
1850 It was downloaded from http://subtitleripper.sourceforge.net/
1851
1852=== added file 'debian/docs'
1853--- debian/docs 1970-01-01 00:00:00 +0000
1854+++ debian/docs 2013-11-19 19:50:12 +0000
1855@@ -0,0 +1,1 @@
1856+README*
1857
1858=== added file 'debian/install'
1859--- debian/install 1970-01-01 00:00:00 +0000
1860+++ debian/install 2013-11-19 19:50:12 +0000
1861@@ -0,0 +1,7 @@
1862+srttool usr/bin
1863+subtitle2pgm usr/bin
1864+pgm2txt usr/bin
1865+vobsub2pgm usr/bin
1866+subtitle2vobsub usr/bin
1867+*.sed usr/share/subtitleripper
1868+debian/gocrfilter_fr.sed usr/share/subtitleripper
1869
1870=== added file 'debian/manpages'
1871--- debian/manpages 1970-01-01 00:00:00 +0000
1872+++ debian/manpages 2013-11-19 19:50:12 +0000
1873@@ -0,0 +1,1 @@
1874+debian/subtitle2pgm.1
1875
1876=== removed file 'debian/patches/00list'
1877--- debian/patches/00list 2011-02-17 21:10:09 +0000
1878+++ debian/patches/00list 1970-01-01 00:00:00 +0000
1879@@ -1,3 +0,0 @@
1880-01_pgm2txt
1881-02_Makefile
1882-03_binutils-gold.dpatch
1883
1884=== removed file 'debian/patches/01_pgm2txt.dpatch'
1885--- debian/patches/01_pgm2txt.dpatch 2006-05-28 15:59:33 +0000
1886+++ debian/patches/01_pgm2txt.dpatch 1970-01-01 00:00:00 +0000
1887@@ -1,59 +0,0 @@
1888-#! /bin/sh /usr/share/dpatch/dpatch-run
1889-## 01_configure.dpatch by Christian Marillat <marillat@debian.org>
1890-##
1891-## All lines beginning with ## DP:' are a description of the patch.
1892-## DP: Fix the path for sed file.
1893-
1894-@DPATCH@
1895-
1896---- subtitleripper-0.3.4.orig/pgm2txt 2004-11-18 13:59:04.000000000 +0100
1897-+++ subtitleripper-0.3.4/pgm2txt 2004-11-18 14:00:25.000000000 +0100
1898-@@ -16,7 +16,7 @@
1899- # Adjust this path to where the files
1900- # gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed
1901- # are located
1902--PATH_TO_LANGUAGE_FILTER=~/sourceforge/subtitleripper/src/
1903-+PATH_TO_LANGUAGE_FILTER=/usr/share/subtitleripper
1904-
1905- # set your options for gocr. Please read the gocr
1906- # docs to find out more about this
1907-@@ -35,8 +35,8 @@
1908- # Choose your favorite image viewer if you want to see
1909- # the current pgm image while gocr is running.
1910- # Enable the viewer with -v command line option.
1911--IMAGE_VIWER=xv
1912--IMAGE_VIEWER_OPTIONS=-q
1913-+IMAGE_VIEWER=display
1914-+IMAGE_VIEWER_OPTIONS=
1915-
1916- ###### End of configuration section #########
1917-
1918-@@ -108,8 +108,8 @@
1919- shift $(($OPTIND - 1))
1920- PGM_BASE_NAME=$1
1921-
1922--if [ -f ${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed ]; then
1923-- FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed
1924-+if [ -f ${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed ]; then
1925-+ FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed
1926- echo "Using ${FILTER_SCRIPT} to filter gocr output"
1927- else
1928- echo " ------------------------------------------------"
1929-@@ -153,7 +153,7 @@
1930-
1931- echo "Converting $i into text"
1932- if [ ! "$DISPLAY_PGM" = "false" ]; then
1933-- ${IMAGE_VIWER} ${IMAGE_VIEWER_OPTIONS} $i &
1934-+ ${IMAGE_VIEWER} ${IMAGE_VIEWER_OPTIONS} $i &
1935- fi
1936- if [ "none" = "${LANGUAGE}" ]; then
1937- gocr ${GOCR_OPTIONS} -p ${DB_PATH} $i > $i.txt
1938-@@ -163,7 +163,7 @@
1939-
1940- # close the viewer
1941- if [ ! "$DISPLAY_PGM" = "false" ]; then
1942-- killall ${IMAGE_VIWER}
1943-+ killall ${IMAGE_VIEWER}
1944- fi
1945-
1946- done
1947
1948=== added file 'debian/patches/01_pgm2txt.patch'
1949--- debian/patches/01_pgm2txt.patch 1970-01-01 00:00:00 +0000
1950+++ debian/patches/01_pgm2txt.patch 2013-11-19 19:50:12 +0000
1951@@ -0,0 +1,51 @@
1952+--- subtitleripper-0.3.4.orig/pgm2txt 2004-11-18 13:59:04.000000000 +0100
1953++++ subtitleripper-0.3.4/pgm2txt 2004-11-18 14:00:25.000000000 +0100
1954+@@ -16,7 +16,7 @@
1955+ # Adjust this path to where the files
1956+ # gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed
1957+ # are located
1958+-PATH_TO_LANGUAGE_FILTER=~/sourceforge/subtitleripper/src/
1959++PATH_TO_LANGUAGE_FILTER=/usr/share/subtitleripper
1960+
1961+ # set your options for gocr. Please read the gocr
1962+ # docs to find out more about this
1963+@@ -35,8 +35,8 @@
1964+ # Choose your favorite image viewer if you want to see
1965+ # the current pgm image while gocr is running.
1966+ # Enable the viewer with -v command line option.
1967+-IMAGE_VIWER=xv
1968+-IMAGE_VIEWER_OPTIONS=-q
1969++IMAGE_VIEWER=display
1970++IMAGE_VIEWER_OPTIONS=
1971+
1972+ ###### End of configuration section #########
1973+
1974+@@ -108,8 +108,8 @@
1975+ shift $(($OPTIND - 1))
1976+ PGM_BASE_NAME=$1
1977+
1978+-if [ -f ${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed ]; then
1979+- FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed
1980++if [ -f ${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed ]; then
1981++ FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed
1982+ echo "Using ${FILTER_SCRIPT} to filter gocr output"
1983+ else
1984+ echo " ------------------------------------------------"
1985+@@ -153,7 +153,7 @@
1986+
1987+ echo "Converting $i into text"
1988+ if [ ! "$DISPLAY_PGM" = "false" ]; then
1989+- ${IMAGE_VIWER} ${IMAGE_VIEWER_OPTIONS} $i &
1990++ ${IMAGE_VIEWER} ${IMAGE_VIEWER_OPTIONS} $i &
1991+ fi
1992+ if [ "none" = "${LANGUAGE}" ]; then
1993+ gocr ${GOCR_OPTIONS} -p ${DB_PATH} $i > $i.txt
1994+@@ -163,7 +163,7 @@
1995+
1996+ # close the viewer
1997+ if [ ! "$DISPLAY_PGM" = "false" ]; then
1998+- killall ${IMAGE_VIWER}
1999++ killall ${IMAGE_VIEWER}
2000+ fi
2001+
2002+ done
2003
2004=== removed file 'debian/patches/02_Makefile.dpatch'
2005--- debian/patches/02_Makefile.dpatch 2009-09-26 19:34:58 +0000
2006+++ debian/patches/02_Makefile.dpatch 1970-01-01 00:00:00 +0000
2007@@ -1,29 +0,0 @@
2008-#! /bin/sh /usr/share/dpatch/dpatch-run
2009-## 01_configure.dpatch by Christian Marillat <marillat@debian.org>
2010-##
2011-## All lines beginning with ## DP:' are a description of the patch.
2012-## DP: Lynk against netpbm instead of ppm
2013-
2014-@DPATCH@
2015-diff -urNad subtitleripper-0.3.4~/Makefile subtitleripper-0.3.4/Makefile
2016---- subtitleripper-0.3.4~/Makefile 2003-12-08 10:28:02.000000000 +0100
2017-+++ subtitleripper-0.3.4/Makefile 2009-09-26 19:34:52.000000000 +0200
2018-@@ -9,7 +9,7 @@
2019-
2020- ### enable ppm support ###
2021- DEFINES += -D_HAVE_LIB_PPM_
2022--LIBS += -lppm
2023-+LIBS += -lnetpbm
2024-
2025- ### enable PNG support ###
2026- DEFINES += -D_HAVE_PNG_
2027-@@ -19,6 +19,9 @@
2028- DEFINES += -D_HAVE_ZLIB_
2029- LIBS += -lz
2030-
2031-+### getline is defined for us
2032-+DEFINES += -DHAVE_GETLINE
2033-+
2034- CC = gcc
2035- WARN = -Wall -Wstrict-prototypes
2036- COPT = -g -O2
2037
2038=== added file 'debian/patches/02_Makefile.patch'
2039--- debian/patches/02_Makefile.patch 1970-01-01 00:00:00 +0000
2040+++ debian/patches/02_Makefile.patch 2013-11-19 19:50:12 +0000
2041@@ -0,0 +1,67 @@
2042+Index: subtitleripper-0.3.4/Makefile
2043+===================================================================
2044+--- subtitleripper-0.3.4.orig/Makefile 2012-07-27 15:09:43.324754534 +0200
2045++++ subtitleripper-0.3.4/Makefile 2012-07-27 15:10:51.803406418 +0200
2046+@@ -9,7 +9,7 @@
2047+
2048+ ### enable ppm support ###
2049+ DEFINES += -D_HAVE_LIB_PPM_
2050+-LIBS += -lppm
2051++LIBS += -lnetpbm
2052+
2053+ ### enable PNG support ###
2054+ DEFINES += -D_HAVE_PNG_
2055+ @@ -19,6 +19,9 @@
2056+ DEFINES += -D_HAVE_ZLIB_
2057+ LIBS += -lz
2058+
2059++### getline is defined for us
2060++DEFINES += -DHAVE_GETLINE
2061++
2062+ CC = gcc
2063+ WARN = -Wall -Wstrict-prototypes
2064+ COPT = -g -O2
2065+@@ -57,7 +57,7 @@
2066+
2067+ %.o:%.c
2068+ @echo Compiling $<
2069+- @$(CC) -c $(CFLAGS) $<
2070++ @$(CC) -c $(CFLAGS) $(CPPFLAGS) $<
2071+
2072+ # Dependencies
2073+ subtitle2pgm.o: subtitle2pgm.c spudec.h subtitle2pgm.h
2074+@@ -70,19 +70,19 @@
2075+ # Target
2076+ subtitle2pgm: subtitle2pgm.o spudec.o
2077+ @echo "Linking $@"
2078+- @$(CC) $(LIBS) $^ -o $@
2079++ @$(CC) $(LIBS) $(LDFLAGS) $^ -o $@
2080+
2081+ subtitle2vobsub: subtitle2vobsub.o vobsub.o
2082+ @echo "Linking $@"
2083+- @$(CC) $(LIBS) $^ -o $@
2084++ @$(CC) $(LIBS) $(LDFLAGS) $^ -o $@
2085+
2086+ srttool: srttool.o
2087+ @echo "Linking $@"
2088+- @$(CC) $(LIBS) -g $^ -o $@
2089++ @$(CC) $(LIBS) $(LDFLAGS) -g $^ -o $@
2090+
2091+ vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
2092+ @echo "Linking $@"
2093+- @$(CC) $(LIBS) -g $^ -o $@
2094++ @$(CC) $(LIBS) $(LDFLAGS) -g $^ -o $@
2095+
2096+ .PHONY: clean dist rpm
2097+ clean:
2098+@@ -107,10 +107,3 @@
2099+ @rm $(PACKAGE)-$(VERSION)-$(RELEASE).tgz
2100+ sudo cp subtitleripper.spec /usr/src/packages/SPECS/
2101+ sudo rpm -ba /usr/src/packages/SPECS/subtitleripper.spec
2102+-
2103+-
2104+-
2105+-
2106+-
2107+-
2108+-
2109
2110=== removed file 'debian/patches/03_binutils-gold.dpatch'
2111--- debian/patches/03_binutils-gold.dpatch 2011-02-17 21:10:09 +0000
2112+++ debian/patches/03_binutils-gold.dpatch 1970-01-01 00:00:00 +0000
2113@@ -1,33 +0,0 @@
2114-#! /bin/sh /usr/share/dpatch/dpatch-run
2115-## Description: Fix FTBFS binutils-gold with ld as-needed
2116-## Author: Mahyuddin Susanto <udienz@ubuntu.com>
2117-## Bug: https://launchpad.net/bugs/720725
2118-
2119-@DPATCH@
2120-diff -urNad subtitleripper-0.3.4~/Makefile subtitleripper-0.3.4/Makefile
2121---- subtitleripper-0.3.4~/Makefile 2011-02-17 20:51:42.183047389 +0700
2122-+++ subtitleripper-0.3.4/Makefile 2011-02-17 20:52:02.291199592 +0700
2123-@@ -73,19 +73,19 @@
2124- # Target
2125- subtitle2pgm: subtitle2pgm.o spudec.o
2126- @echo "Linking $@"
2127-- @$(CC) $(LIBS) $^ -o $@
2128-+ @$(CC) $^ -o $@ $(LIBS)
2129-
2130- subtitle2vobsub: subtitle2vobsub.o vobsub.o
2131- @echo "Linking $@"
2132-- @$(CC) $(LIBS) $^ -o $@
2133-+ @$(CC) $^ -o $@ $(LIBS)
2134-
2135- srttool: srttool.o
2136- @echo "Linking $@"
2137-- @$(CC) $(LIBS) -g $^ -o $@
2138-+ @$(CC) -g $^ -o $@ $(LIBS)
2139-
2140- vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
2141- @echo "Linking $@"
2142-- @$(CC) $(LIBS) -g $^ -o $@
2143-+ @$(CC) -g $^ -o $@ $(LIBS)
2144-
2145- .PHONY: clean dist rpm
2146- clean:
2147
2148=== added file 'debian/patches/03_binutils-gold.patch'
2149--- debian/patches/03_binutils-gold.patch 1970-01-01 00:00:00 +0000
2150+++ debian/patches/03_binutils-gold.patch 2013-11-19 19:50:12 +0000
2151@@ -0,0 +1,34 @@
2152+Description: Fix FTBFS binutils-gold with ld as-needed
2153+Author: Mahyuddin Susanto <udienz@ubuntu.com>
2154+Bug: https://launchpad.net/bugs/720725
2155+
2156+---
2157+ Makefile | 8 ++++----
2158+ 1 file changed, 4 insertions(+), 4 deletions(-)
2159+
2160+--- a/Makefile
2161++++ b/Makefile
2162+@@ -70,19 +70,19 @@ vobsub2pgm.o: vobsub2pgm.c vobsub.h spud
2163+ # Target
2164+ subtitle2pgm: subtitle2pgm.o spudec.o
2165+ @echo "Linking $@"
2166+- @$(CC) $(LIBS) $^ -o $@
2167++ @$(CC) $^ -o $@ $(LIBS)
2168+
2169+ subtitle2vobsub: subtitle2vobsub.o vobsub.o
2170+ @echo "Linking $@"
2171+- @$(CC) $(LIBS) $^ -o $@
2172++ @$(CC) $^ -o $@ $(LIBS)
2173+
2174+ srttool: srttool.o
2175+ @echo "Linking $@"
2176+- @$(CC) $(LIBS) -g $^ -o $@
2177++ @$(CC) -g $^ -o $@ $(LIBS)
2178+
2179+ vobsub2pgm: vobsub2pgm.o vobsub.o spudec.o
2180+ @echo "Linking $@"
2181+- @$(CC) $(LIBS) -g $^ -o $@
2182++ @$(CC) -g $^ -o $@ $(LIBS)
2183+
2184+ .PHONY: clean dist rpm
2185+ clean:
2186
2187=== added file 'debian/patches/03_getline.diff'
2188--- debian/patches/03_getline.diff 1970-01-01 00:00:00 +0000
2189+++ debian/patches/03_getline.diff 2013-11-19 19:50:12 +0000
2190@@ -0,0 +1,13 @@
2191+Index: subtitleripper-0.3.4/vobsub.c
2192+===================================================================
2193+--- subtitleripper-0.3.4.orig/vobsub.c 2010-02-11 12:10:06.000000000 +0100
2194++++ subtitleripper-0.3.4/vobsub.c 2010-02-11 12:10:34.000000000 +0100
2195+@@ -18,7 +18,7 @@
2196+ * Some code freely inspired from VobSub <URL:http://vobsub.edensrising.com>,
2197+ * with kind permission from Gabest <gabest@freemail.hu>
2198+ */
2199+-/* #define HAVE_GETLINE */
2200++#define HAVE_GETLINE
2201+ #include <ctype.h>
2202+ #include <errno.h>
2203+ #include <stdio.h>
2204
2205=== added file 'debian/patches/series'
2206--- debian/patches/series 1970-01-01 00:00:00 +0000
2207+++ debian/patches/series 2013-11-19 19:50:12 +0000
2208@@ -0,0 +1,4 @@
2209+03_getline.diff
2210+01_pgm2txt.patch
2211+02_Makefile.patch
2212+03_binutils-gold.patch
2213
2214=== modified file 'debian/rules'
2215--- debian/rules 2006-05-28 15:59:33 +0000
2216+++ debian/rules 2013-11-19 19:50:12 +0000
2217@@ -1,70 +1,10 @@
2218 #!/usr/bin/make -f
2219
2220-#export DH_VERBOSE=1
2221-
2222-include /usr/share/dpatch/dpatch.make
2223-
2224-DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
2225-DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
2226-
2227-ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
2228- CFLAGS += -g
2229-endif
2230-
2231-CFLAGS = -Wall -g
2232-
2233-ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
2234- INSTALL_PROGRAM += -s
2235-endif
2236-
2237-build: build-stamp
2238-build-stamp: patch-stamp
2239- dh_testdir
2240-
2241- $(MAKE)
2242-
2243- touch build-stamp
2244-
2245-clean:
2246- dh_testdir
2247- dh_testroot
2248- rm -f build-stamp
2249-
2250- $(MAKE) clean
2251-
2252- debian/rules unpatch
2253-
2254+%:
2255+ dh $@ --with quilt
2256+
2257+override_dh_clean:
2258 dh_clean subtitle2vobsub.o vobsub2pgm.o
2259
2260-install: build
2261- dh_testdir
2262- dh_testroot
2263- dh_clean -k
2264- dh_installdirs usr/bin usr/share/subtitleripper
2265-
2266- cp srttool subtitle2pgm pgm2txt debian/subtitleripper/usr/bin
2267- cp vobsub2pgm subtitle2vobsub debian/subtitleripper/usr/bin
2268- cp *.sed debian/subtitleripper/usr/share/subtitleripper
2269- cp debian/gocrfilter_fr.sed debian/subtitleripper/usr/share/subtitleripper
2270-
2271-# Build architecture-independent files here.
2272-binary-indep: build install
2273-
2274-# Build architecture-dependent files here.
2275-binary-arch: build install
2276- dh_testdir
2277- dh_testroot
2278- dh_installdocs README*
2279- dh_installchangelogs ChangeLog
2280- dh_link
2281- dh_strip
2282- dh_compress
2283- dh_fixperms
2284- dh_installdeb
2285- dh_shlibdeps
2286- dh_gencontrol
2287- dh_md5sums
2288- dh_builddeb
2289-
2290-binary: binary-indep binary-arch
2291-.PHONY: build clean binary-indep binary-arch binary install patch unpatch
2292+override_dh_builddeb:
2293+ dh_builddeb -- -Zbzip2
2294\ No newline at end of file
2295
2296=== added directory 'debian/source'
2297=== added file 'debian/source/format'
2298--- debian/source/format 1970-01-01 00:00:00 +0000
2299+++ debian/source/format 2013-11-19 19:50:12 +0000
2300@@ -0,0 +1,1 @@
2301+1.0
2302
2303=== added file 'debian/subtitle2pgm.1'
2304--- debian/subtitle2pgm.1 1970-01-01 00:00:00 +0000
2305+++ debian/subtitle2pgm.1 2013-11-19 19:50:12 +0000
2306@@ -0,0 +1,163 @@
2307+.TH "subtitle2pgm" "1" "" "Arne Driescher" "multimedia"
2308+.SH "NAME"
2309+.LP
2310+subtitle2pgm \- Convert a subtitle stream to pgm images.
2311+.SH "SYNTAX"
2312+.LP
2313+subtitle2pgm [\fI\-i\fP <\fIfilename\fP>]
2314+[\fI\-o\fP <\fIbasename\fP>]
2315+[\fI\-c\fP <\fIc0,c1,c2,c3\fP>]
2316+[\fI\-g\fP <\fIformat\fP>]
2317+[\fI\-t\fP <\fIformat\fP>]
2318+[\fI\-l\fP <\fIseconds\fP>]
2319+[\fI\-C\fP <\fIborder\fP>]
2320+[\fI\-e\fP <\fIhh:mm:ss,n\fP>]
2321+[\fI\-v\fP]
2322+[\fI\-P\fP]
2323+.br
2324+.SH "DESCRIPTION"
2325+.LP
2326+\fBsubtitle2pgm\fR converts a subtitle stream to pgm images,
2327+(see: \fBpgm(5)\fR).
2328+The subtitle stream is produced by
2329+\fBtcextract(1)\fR, e.g.
2330+
2331+ tcextract \-x ps1 \-t vob \-a 0x20 \-i file.vob
2332+
2333+and are piped directly into \fBsubtitle2pgm\fR, e.g.
2334+
2335+ tcextract \-x ps1 \-t vob \-a 0x20 \-i file.vob | subtitle2pgm
2336+
2337+If the subtitle stream already exists as a file,
2338+use the \fB\-i\fR option to read from it, e.g.
2339+
2340+ subtitle2pgm \-i subtitle_stream.ps1
2341+
2342+.SH "OPTIONS"
2343+.LP
2344+.TP
2345+
2346+\fB\-i\fR <\fIfilename\fP>
2347+Use <\fIfilename\fP> for input instead of stdin.
2348+.TP
2349+
2350+\fB\-o\fR <\fIname\fP>
2351+Use <\fIname\fP> as the basename for output files. If no <\fIname\fP> was given,
2352+it defaults to "\fBmovie_subtitle\fR".
2353+Output file names are of the form \fBnameXXXX.pgm\fR
2354+where \fBXXXX\fR is a title number. Caution: existing files
2355+will be overwritten without warning.
2356+.TP
2357+
2358+\fB\-c\fR <\fIc0,c1,c2,c3\fP>
2359+Override the default grey levels in output image.
2360+Default is \fB255,255,0,255\fR. Valid values are in the range
2361+\fB0\fR<=\fBc\fR<=\fB255\fR where \fB0\fR is black and \fB255\fR white.
2362+.TP
2363+
2364+\fB\-g\fR <\fIformat\fP>
2365+Set output image format, where \fBformat\fR is a number from 0 to 5.
2366+.br
2367+ 0 PGM (default)
2368+.br
2369+ 1 PPM
2370+.br
2371+ 2 PGM.GZ
2372+.br
2373+ 3 PNG_GRAY (simple gray image)
2374+.br
2375+ 4 PNG_GRAY_ALPHA (gray image with alpha channel)
2376+.br
2377+ 5 PNG_RGAB (8 bit RGB + alpha channel).
2378+.br
2379+
2380+PPM and PGM.GZ output won't work unless the program was compiled with support
2381+for it. \fB\-g 2\fR is recommended to save disk space.
2382+.TP
2383+
2384+\fB\-t\fR <\fIformat\fP>
2385+Set the output format, where \fBformat\fR is a number from 0 to 1.
2386+.br
2387+ 0 (default) srtx\-files used by \fBsrttool\fR (see README.srttool)
2388+.br
2389+ 1 XML file format usable by \fBDVDauthor\fR ( http://dvdauthor.sourceforge.net/ ).
2390+.TP
2391+
2392+\fB\-l\fR <\fIseconds\fP>
2393+Add <seconds> to PTS (\fBP\fRresentation \fBT\fRime \fBS\fRtamp) for every DVD\-9 layer skip (default 0.0).
2394+The internal PTS in VOB files
2395+is reset to 0 when a new layer is started. This
2396+is already handled by \fBtcextract\fR and should not be
2397+noticeable in \fBsubtitle2pgm\fR. If for some reason the timing
2398+is misadjusted after a layer skip, try adding
2399+an appropriate offset with this option.
2400+.TP
2401+
2402+\fB\-C\fR <\fIborder\fP>
2403+Reduce border around the text to <border>
2404+pixels. Many DVDs come with full screen
2405+subtitles where only a tiny part is really
2406+covered with text. Thus saving only the
2407+interesting part of the image saves space
2408+on your hard disk. Default: Don't crop.
2409+Usually this option is used with a small value for <border> e.g. \fB\-C 0\fR.
2410+.TP
2411+
2412+\fB\-e\fR <\fIhh:mm:ss,n\fP>
2413+Extract only \fBn\fR subtitles starting from the
2414+time stamp \fBhh:mm:ss\fR. This gives a preview
2415+of what the subtitles would look like. E.g.
2416+\fB\-e 00:05:00,10\fR
2417+skips the first 5 minutes then
2418+outputs the next 10 subtitles.
2419+.TP
2420+
2421+\fB\-v\fR
2422+Enables more output messages that
2423+usually aren't needed.
2424+.TP
2425+
2426+\fB\-P\fR
2427+Write a progress report to show the program is doing something useful.
2428+
2429+.SH "EXAMPLES"
2430+.LP
2431+Suppose the current directory is a mounted DVD of "Foo", or contains the VOB
2432+files from the DVD.
2433+
2434+ # change these as needed
2435+.br
2436+ MOVIE="Foo" # name of movie
2437+.br
2438+ TITLENO=1 # subtitle language number
2439+.br
2440+ VOBSET="`echo VTS_01_[0\-9].VOB`" # not all movies start at '0'
2441+
2442+ # make 'pgm' files of the subtitles
2443+.br
2444+ cat $VOBSET | tcextract \-x ps1 \-t vob \-a 0x2$TITLENO | subtitle2pgm \-o "$MOVIE"
2445+.br
2446+ # Use OCR to convert them to text, (imperfectly)
2447+.br
2448+ pgm2txt \-f en "$MOVIE"
2449+.br
2450+ # make a '.srt' file of it.
2451+.br
2452+ srttool \-s \-i "$MOVIE".srtx \-o "$MOVIE".srt
2453+
2454+The result is usually over a thousand '.pgm' and '.pgm.txt' files,
2455+plus the desired '.srt' file. The '.srt' file will only be as good
2456+as the OCR, so expect errors.
2457+
2458+View the resulting '.srt' over the movie, in a large antialiased yellow font:
2459+
2460+ mplayer \-sub "$MOVIE".srt $VOBSET \-ass \-ass\-color ffff0000 \-ass\-border\-color 00000000 \-ass\-font\-scale 1.8 \-fontconfig \-font Verdana
2461+
2462+
2463+.LP
2464+.SH "AUTHOR"
2465+.LP
2466+Arne Driescher, with tweaks and examples by A. Costa.
2467+.SH "SEE ALSO"
2468+.LP
2469+tcextract(1), pgm(5)
2470
2471=== modified file 'debian/watch'
2472--- debian/watch 2006-05-28 15:59:33 +0000
2473+++ debian/watch 2013-11-19 19:50:12 +0000
2474@@ -1,3 +1,4 @@
2475 version=3
2476
2477+opts="uversionmangle=s/-/./" \
2478 http://sf.net/subtitleripper/subtitleripper-(.*)\.tgz
2479
2480=== modified file 'pgm2txt'
2481--- pgm2txt 2004-02-07 09:36:58 +0000
2482+++ pgm2txt 2013-11-19 19:50:12 +0000
2483@@ -16,7 +16,7 @@
2484 # Adjust this path to where the files
2485 # gocrfilter_en.sed gocrfilter_fr.sed gocrfilter_none.sed
2486 # are located
2487-PATH_TO_LANGUAGE_FILTER=~/sourceforge/subtitleripper/src/
2488+PATH_TO_LANGUAGE_FILTER=/usr/share/subtitleripper
2489
2490 # set your options for gocr. Please read the gocr
2491 # docs to find out more about this
2492@@ -35,8 +35,8 @@
2493 # Choose your favorite image viewer if you want to see
2494 # the current pgm image while gocr is running.
2495 # Enable the viewer with -v command line option.
2496-IMAGE_VIWER=xv
2497-IMAGE_VIEWER_OPTIONS=-q
2498+IMAGE_VIEWER=display
2499+IMAGE_VIEWER_OPTIONS=
2500
2501 ###### End of configuration section #########
2502
2503@@ -108,8 +108,8 @@
2504 shift $(($OPTIND - 1))
2505 PGM_BASE_NAME=$1
2506
2507-if [ -f ${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed ]; then
2508- FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}gocrfilter_${LANGUAGE}.sed
2509+if [ -f ${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed ]; then
2510+ FILTER_SCRIPT=${PATH_TO_LANGUAGE_FILTER}/gocrfilter_${LANGUAGE}.sed
2511 echo "Using ${FILTER_SCRIPT} to filter gocr output"
2512 else
2513 echo " ------------------------------------------------"
2514@@ -153,7 +153,7 @@
2515
2516 echo "Converting $i into text"
2517 if [ ! "$DISPLAY_PGM" = "false" ]; then
2518- ${IMAGE_VIWER} ${IMAGE_VIEWER_OPTIONS} $i &
2519+ ${IMAGE_VIEWER} ${IMAGE_VIEWER_OPTIONS} $i &
2520 fi
2521 if [ "none" = "${LANGUAGE}" ]; then
2522 gocr ${GOCR_OPTIONS} -p ${DB_PATH} $i > $i.txt
2523@@ -163,7 +163,7 @@
2524
2525 # close the viewer
2526 if [ ! "$DISPLAY_PGM" = "false" ]; then
2527- killall ${IMAGE_VIWER}
2528+ killall ${IMAGE_VIEWER}
2529 fi
2530
2531 done
2532
2533=== modified file 'vobsub.c'
2534--- vobsub.c 2004-02-07 09:36:58 +0000
2535+++ vobsub.c 2013-11-19 19:50:12 +0000
2536@@ -18,7 +18,7 @@
2537 * Some code freely inspired from VobSub <URL:http://vobsub.edensrising.com>,
2538 * with kind permission from Gabest <gabest@freemail.hu>
2539 */
2540-/* #define HAVE_GETLINE */
2541+#define HAVE_GETLINE
2542 #include <ctype.h>
2543 #include <errno.h>
2544 #include <stdio.h>

Subscribers

People subscribed via source and target branches

to all changes: