changeset 96:2fcb4f228308 src

Adding "Personalizing DVD Viewing" files from <kevin_smathers@hp.com> Not yet enabled. Will be enabled soon.
author jcdutton
date Tue, 17 Sep 2002 10:47:02 +0000
parents e7ebabe059b9
children c1dff1899bda
files FELLOWSHIP.map README.MAP remap.c remap.h
diffstat 4 files changed, 506 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FELLOWSHIP.map	Tue Sep 17 10:47:02 2002 +0000
@@ -0,0 +1,163 @@
+# The Lord of the Rings: Fellowship of the Ring (Widescreen Theatrical Release)
+domain 8, title 1, program 1, start 0x0000, end 0x1f0a   # Introduction
+
+# history of middle earth
+#domain 2, title 1, program 1, start 0x9cba, end 0xcea4   # violence/war
+#domain 2, title 1, program 1, start 0xf018, end 0x1272c  # violence/war
+domain 2, title 1, program 1, start 0x11ff3, end 0x1272c # gore
+#domain 2, title 1, program 1, start 0x173f1, end 0x185d6 # violence/death
+
+# hobbiton 
+domain 2, title 1, program 2, start 0x30373, end 0x31946 # vices/smoking
+domain 2, title 1, program 2, start 0x32942, end 0x34426 # vices/smoking
+domain 2, title 1, program 2, start 0x34895, end 0x34ad1 # vices/smoking
+domain 2, title 1, program 2, start 0x3965c, end 0x39d7c # vices/smoking
+
+# bag end
+domain 2, title 1, program 3, start 0x40288, end 0x412de # vices/drinking/talk
+domain 2, title 1, program 3, start 0x4cfbe, end 0x4f955 # vices/smoking
+
+# party
+domain 2, title 1, program 4, start 0x53ee0, end 0x54396 # vices/drinking
+domain 2, title 1, program 4, start 0x58851, end 0x5ae3d # imitative/theft
+domain 2, title 1, program 4, start 0x5cd0a, end 0x5e216 # jump 
+
+# gandalf departs
+domain 2, title 1, program 6, start 0x7f05d, end 0x7f1b3 # jump
+domain 2, title 1, program 6, start 0x7f51a, end 0x834a7 # vices/smoking
+
+# research
+domain 2, title 1, program 7, start 0x8e6e8, end 0x8e9d7 # vices/smoking
+
+# hobbiton
+domain 2, title 1, program 8, start 0x98f49, end 0x990ba # jump
+domain 2, title 1, program 8, start 0xa0ad1, end 0xa17ac # jump
+domain 2, title 1, program 8, start 0xa9e32, end 0xaaa70 # violence/torture
+domain 2, title 1, program 8, start 0xabc6c, end 0xabd92 # violence
+
+# orthanc
+domain 2, title 1, program 9, start 0xd50b7, end 0xd87f9 # violence
+domain 2, title 1, program 9, start 0xd8e49, end 0xda611 # violence
+
+# farmer maggot
+domain 2, title 1, program 10, start 0xde856, end 0xdeb07 # jump
+domain 2, title 1, program 10, start 0xe4cfe, end 0xe50b3 # gore/excrement
+domain 2, title 1, program 10, start 0xebba3, end 0xebf93 # gore/blood
+domain 2, title 1, program 10, start 0xed222, end 0xeda7e # gore/insects
+
+# buckleberry ferry
+domain 2, title 1, program 11, start 0xf6d77, end 0xf83f8 # jump
+
+# prancing pony in bree
+domain 2, title 1, program 12, start 0x10945e, end 0x10a2f2 # vices/drinking/rolemodel
+domain 2, title 1, program 12, start 0x10c103, end 0x10c417 # vices/smoking
+domain 2, title 1, program 12, start 0x10c934, end 0x10cb44 # vices/smoking
+# 10c934
+# 10c9b4
+# 10ca3c
+# 10cad6
+# 10cb44
+# 10cbb4
+domain 2, title 1, program 12, start 0x10ddab, end 0x10e0f2 # vices/smoking
+domain 2, title 1, program 12, start 0x10e1df, end 0x10e411 # vices/drinking
+
+# ring wraiths in bree
+domain 2, title 1, program 13, start 0x117853, end 0x117f6e # violence
+domain 2, title 1, program 13, start 0x117853, end 0x117f6e # gore/crushing
+domain 2, title 1, program 13, start 0x11b2b3, end 0x11bffc # violence
+
+# weathertop
+#domain 2, title 1, program 15, start 0x13b85b, end 0x141b38 # violence
+domain 2, title 1, program 15, start 0x14093a, end 0x141063 # gore/stabbing
+domain 2, title 1, program 15, start 0x142555, end 0x1466e9 # violence
+
+# isengard
+domain 2, title 1, program 16, start 0x152a28, end 0x1549fb # violence
+domain 2, title 1, program 16, start 0x152a28, end 0x1549fb # gore
+
+# the ford
+domain 2, title 1, program 17, start 0x173dbe, end 0x1748a6 # violence
+
+# rivendell
+domain 2, title 1, program 18, start 0x179793, end 0x17a667 # vices/smoking
+domain 2, title 1, program 18, start 0x17c452, end 0x17eab6 # violence
+
+# rivendell
+domain 2, title 1, program 20, start 0x19caaf, end 0x19db12 # violence
+
+# tomb of isildur
+domain 2, title 1, program 21, start 0x1a69ae, end 0x1a6a3d # gore/blood
+
+# rivendell
+domain 2, title 1, program 22, start 0x1b298b, end 0x1b2bae # kiss
+
+# rivendell
+domain 2, title 1, program 24, start 0x1d8253, end 0x1d8f5d # horror/posession
+
+# on the road south
+domain 2, title 1, program 25, start 0x1e2fc2, end 0x1e31b8 # vices/smoking
+
+# at the entrance to moria
+domain 2, title 1, program 27, start 0x214bdd, end 0x214fcc # gore/skeletons
+domain 2, title 1, program 27, start 0x2157d9, end 0x216731 # gore/skeletons
+domain 2, title 1, program 27, start 0x217ba6, end 0x21cdb4 # violence
+
+# moria
+#domain 2, title 1, program 28, start 0x22173d, end 0x221e58 # gore/skeletons
+#domain 2, title 1, program 28, start 0x222e0b, end 0x223345 # gore/skeletons
+domain 2, title 1, program 28, start 0x22173d, end 0x223345 # gore/skeletons
+domain 2, title 1, program 28, start 0x2239e2, end 0x223e8c # gore/skeletons
+domain 2, title 1, program 28, start 0x22589f, end 0x2259bf # vices/smoking
+
+# balin's tomb
+domain 2, title 1, program 29, start 0x234abb, end 0x234dd0 # gore/skeletons
+domain 2, title 1, program 29, start 0x2352ed, end 0x2361d7 # gore/skeletons
+domain 2, title 1, program 29, start 0x23898b, end 0x23955c # gore/skeletons
+domain 2, title 1, program 29, start 0x23b467, end 0x23db2b # gore/skeletons
+#domain 2, title 1, program 29, start 0x247360, end 0x25e24b # violence
+domain 2, title 1, program 29, start 0x2483b6, end 0x248b62 # gore/impalement
+domain 2, title 1, program 29, start 0x24a606, end 0x24a9f3 # gore/headshot
+domain 2, title 1, program 29, start 0x24acd8, end 0x24ae7e # gore/decapitation
+domain 2, title 1, program 29, start 0x24d708, end 0x24d88f # gore/bashing
+domain 2, title 1, program 29, start 0x25013a, end 0x250501 # gore/impalement
+domain 2, title 1, program 29, start 0x2540a0, end 0x254507 # jump
+domain 2, title 1, program 29, start 0x2560b3, end 0x256423 # gore/impalement
+domain 2, title 1, program 29, start 0x258152, end 0x258459 # gore/impalement
+domain 2, title 1, program 29, start 0x258152, end 0x258459 # gore/impalement
+
+# the bridge
+#domain 2, title 1, program 30, start 0x274235, end 0x275e59 # violence
+domain 2, title 1, program 30, start 0x2744c6, end 0x274a5e # gore/headshot
+domain 2, title 1, program 30, start 0x275661, end 0x275e59 # violence/death
+domain 2, title 1, program 30, start 0x289d2a, end 0x28a066 # gore/falling
+
+# lothlorien
+domain 2, title 1, program 32, start 0x2be304, end 0x2beb1d # violence
+domain 2, title 1, program 32, start 0x2c5d59, end 0x2c9a40 # horror/posession
+#domain 2, title 1, program 32, start 0x2c5d59, end 0x2c9e41 # horror/posession
+
+# parth galen
+domain 2, title 1, program 36, start 0x2fa317, end 0x2fb0b0 # violence
+
+# parth galen w/ orcs
+domain 2, title 1, program 37, start 0x30c8cb, end 0x313054 # violence
+domain 2, title 1, program 37, start 0x310428, end 0x313054 # gore/impalement
+#domain 2, title 1, program 37, start 0x317f45, end 0x332a52 # violence
+domain 2, title 1, program 37, start 0x322d8b, end 0x328f4d # gore/impalement
+domain 2, title 1, program 37, start 0x32f2a4, end 0x330731 # gore/impalement
+domain 2, title 1, program 37, start 0x330b3b, end 0x330c4d # gore/blood
+domain 2, title 1, program 37, start 0x331c4e, end 0x332a52 # gore/dismemberment
+domain 2, title 1, program 37, start 0x331c4e, end 0x332a52 # gore/decapitation
+
+# death of boromir
+domain 2, title 1, program 38, start 0x33322f, end 0x33c10c # gore/bodies
+domain 2, title 1, program 38, start 0x33b558, end 0x33c10c # horror/death
+
+# to the eastern shore
+domain 2, title 1, program 39, start 0x34a25b, end 0x34c1e3 # horror/drowning
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.MAP	Tue Sep 17 10:47:02 2002 +0000
@@ -0,0 +1,105 @@
+Contents
+
+WHAT ARE MAP FILES
+HOWTO
+FINDING MAP FILES
+WHOM TO BLAME
+
+WHAT ARE MAP FILES
+==================
+
+Map files are an experimental feature that lets you customize the way
+you watch DVDs.  If you are opposed to violence, are sickened by gore,
+or would rather your two year old didn't ask you just yet why that 
+woman in the movie was naked, you might want to create a map file.  
+
+Map files identify sections of the movie that will be skipped during
+playback.  You can skip any section you like with the only restriction
+(right now) that the movie player must play at least the last VOBU 
+(about a fifth of a second) of each chapter in the movie in order
+to detect chapter changes correctly.  
+
+Included with this patch is an example map file that describes most
+of the potentially objectionable content in the new "The Lord of the 
+Rings" DVD.  I've added a comment after each block that identifies 
+what content it contains so that you can customize the file to your
+preferences.  The map file looks something like this:
+
+ # The Lord of the Rings: Fellowship of the Ring 
+ # (Widescreen Theatrical Release)
+ debug
+ domain 8, title 1, program 1, start 0x0000, end 0x1f0a   # Introduction
+
+ # history of middle earth
+ #domain 2, title 1, program 1, start 0x9cba, end 0xcea4   # violence/war
+ #domain 2, title 1, program 1, start 0xf018, end 0x1272c  # violence/war
+ domain 2, title 1, program 1, start 0x11ff3, end 0x1272c # gore
+ #domain 2, title 1, program 1, start 0x173f1, end 0x185d6 # violence/death
+
+Place the map file in your .xine directory to enable the selected
+cuts as follows:
+
+    cp FELLOWSHIP.map ~/.xine
+
+The debug command tells the map code that you would like to see the
+VOBU numbers as the movie is playing.  Comment out this line to hide
+this output.  The remaining lines are all either comments or blocks.
+Each block has a start and an end, and whenever Xine tries to load
+a VOBU between the start and end, it will be redirected to the end
+block instead.
+
+
+HOWTO
+=====
+
+To create your own map files you would create a new map file using the
+title of the disk as the filename, and add the debug line to it.  The
+map file should be placed in your '.xine' directory and have a '.map'
+extension added.  For example "The Lord Of The Rings" map must be stored 
+in the file ~/.xine/FELLOWSHIP.map
+
+After you create the file with the DEBUG line you will see output that
+looks like this in window where you started Xine:
+
+   FELLOWSHIP: domain 8, title 1, program 1, start 2205, next 22a8
+   FELLOWSHIP: domain 8, title 1, program 1, start 22a8, next 234b
+   FELLOWSHIP: domain 8, title 1, program 1, start 234b, next 23eb
+   FELLOWSHIP: domain 8, title 1, program 1, start 23eb, next 248a
+
+Each line represents one VOBU, and the start and end addresses match
+the start and end addresses that you should place in the map file
+if you want to skip that block.  If you want to skip multiple blocks
+you would just add one line with the start address of the first block
+to skip, and the end address of the last block to skip.  For example
+to skip these four blocks you would add the following line to your
+map file:
+
+   domain 8, title 1, program 1, start 0x2205, end 0x248a # 4 blocks
+
+Xine uses a buffered input chain so that if you pause the viewer you
+won't find the same VOBU being displayed on the terminal as is 
+currently on the screen.  In my testing the correct VOBU to use if
+you pause exactly on the section you want to cut will be about five
+or six lines above the last one printed to the screen.  Replay the
+scene with the deletion to see if you caught the correct blocks.
+
+
+WHERE TO FIND MAP FILES
+=======================
+
+If you create a map file for a new movie, please send it to me.  If
+there is widespread interest I'll put up a site where map files can
+be located and downloaded.
+
+
+WHOM TO BLAME
+=============
+
+If the patch doesn't work for you (and you want it to) you can contact
+me at 'kevin_smathers@hp.com'.  
+
+If the patch works for you and you don't want it to, remember that 
+not everyone in the world has the same needs.  The freedom to censor 
+movies in our own homes is quite different from the government 
+interfering into libraries and other public forums to censor movies 
+for us.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remap.c	Tue Sep 17 10:47:02 2002 +0000
@@ -0,0 +1,225 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/param.h>
+#include <sys/fcntl.h>
+#include <assert.h>
+#include "remap.h"
+
+struct block_s {
+    int domain;
+    int title;
+    int program;
+    unsigned long start_block;
+    unsigned long end_block;
+};
+
+struct remap_s {
+    char *title;
+    int maxblocks;
+    int nblocks;
+    int debug;
+    struct block_s *blocks;
+};
+
+remap_t* remap_new( char *title) {
+    remap_t *map = malloc( sizeof(remap_t));
+    map->title = strdup(title);
+    map->maxblocks = 0;
+    map->nblocks = 0;
+    map->blocks = NULL;
+    map->debug = 0;
+    return map;
+}
+
+static int compare_block( block_t *a, block_t *b) {
+    /* returns -1 if a precedes b, 1 if a follows b, and 0 if a and b overlap */
+    if (a->domain < b->domain) {
+	return -1;
+    } else if (a->domain > b->domain) {
+	return 1;
+    }
+
+    if (a->title < b->title) {
+	return -1;
+    } else if (a->title > b->title) {
+	return 1;
+    }
+
+    if (a->program < b->program) {
+	return -1;
+    } else if (a->program > b->program) {
+	return 1;
+    }
+
+    if (a->end_block < b->start_block) {
+	return -1;
+    } else if (a->start_block > b->end_block) {
+	/*
+	 * if a->start_block == b->end_block then the two regions
+	 * aren't strictly overlapping, but they should be merged 
+	 * anyway since there are zero blocks between them
+	 */
+	return 1;
+    }
+
+    return 0;
+}
+
+static block_t *findblock( remap_t *map, block_t *key) {
+    int lb = 0;
+    int ub = map->nblocks - 1;
+    int mid;
+    int res;
+
+    while (lb <= ub) {
+	mid = lb + (ub - lb)/2;
+	res = compare_block( key, &map->blocks[mid]);
+	if (res < 0) {
+	    ub = mid-1;
+	} else if (res > 0) {
+	    lb = mid+1;
+	} else {
+	    return &map->blocks[mid];
+	}
+    }
+    return NULL;
+}
+
+static void mergeblock( block_t *b, block_t tmp) {
+    if (tmp.start_block < b->start_block) b->start_block = tmp.start_block;
+    if (tmp.end_block > b->end_block) b->end_block = tmp.end_block;
+}
+
+static void remap_add_node( remap_t *map, block_t block) {
+    block_t *b;
+    int n;
+    b = findblock( map, &block);
+    if (b) {
+	/* overlaps an existing block */
+	mergeblock( b, block);
+    } else {
+        /* new block */
+	if (map->nblocks >= map->maxblocks) {
+	    map->maxblocks += 20;
+	    map->blocks = realloc( map->blocks, sizeof( block_t)*map->maxblocks);
+	}
+	n = map->nblocks++;
+	while (n > 0 && compare_block( &block, &map->blocks[ n-1]) < 0) {
+	    map->blocks[ n] = map->blocks[ n-1];
+	    n--;
+	}
+	map->blocks[ n] = block;
+    }
+}
+
+int parseblock( 
+	char *buf, int *dom, int *tt, int *pg, 
+	unsigned long *start, unsigned long *end) 
+{
+    long tmp;
+    char *tok;
+    char *epos;
+    char *marker[]={"domain", "title", "program", "start", "end"};
+    int st = 0;
+    tok = strtok( buf, " ");
+    while (st < 5) {
+        if (strcmp(tok, marker[st])) return -st-1000;
+        tok = strtok( NULL, " ");
+        if (!tok) return -st-2000;
+        tmp = strtol( tok, &epos, 0);
+        if (*epos != 0 && *epos != ',') return -st-3000;
+        switch (st) {
+	    case 0:
+		*dom = (int)tmp;
+		break;
+	    case 1:
+		*tt = (int)tmp;
+		break;
+	    case 2:
+		*pg = (int)tmp;
+		break;
+	    case 3:
+		*start = tmp;
+		break;
+	    case 4:
+		*end = tmp;
+		break;
+	} 
+	st++;
+        tok = strtok( NULL, " ");
+    }
+    return st;
+}
+
+remap_t* remap_loadmap( char *title) {
+    char buf[160];
+    char fname[MAXPATHLEN];
+    char *home;
+    int res;
+    FILE *fp;
+    block_t tmp;
+    remap_t *map;
+
+    /* Build the map filename */
+    home = getenv("HOME"); assert(home);
+    strncpy(fname, home, sizeof(fname));
+    strncat(fname, "/.xine/", sizeof(fname));
+    strncat(fname, title, sizeof(fname));
+    strncat(fname, ".map", sizeof(fname));
+
+    printf("Loading %s.\n", fname);
+    /* Open the map file */
+    fp = fopen( fname, "r");
+    if (!fp) {
+	printf("Unable to find map file '%s'\n", fname);
+	return NULL;
+    }
+
+    /* Load the map file */
+    map = remap_new( title);
+    while (fgets( buf, sizeof(buf), fp) != NULL) {
+        if (buf[0] == '\n' || buf[0] == '#' || buf[0] == 0) continue;
+        if (strncasecmp( buf, "debug", 5) == 0) {
+	    map->debug = 1;
+	} else {
+	    res = parseblock( buf, 
+		&tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block);
+	    if (res != 5) {
+		printf("Ignoring map line (%d): %s\n", res, buf);
+		continue;
+	    }
+	    remap_add_node( map, tmp);
+	}
+    }
+
+    if (map->nblocks == 0 && map->debug == 0) return NULL;
+    return map;
+}
+
+unsigned long remap_block( 
+	remap_t *map, int domain, int title, int program, 
+	unsigned long cblock, unsigned long offset) 
+{
+    block_t key;
+    block_t *b;
+
+    if (map->debug) {
+	printf("%s: domain %d, title %d, program %d, start %lx, next %lx\n",
+	    map->title, domain, title, program, cblock, cblock+offset);
+    }
+
+    key.domain = domain;
+    key.title = title;
+    key.program = program;
+    key.start_block = key.end_block = cblock + offset;
+    b = findblock( map, &key);
+    
+    if (b) {
+       if (map->debug) {
+	   printf("Redirected to %lx\n", b->end_block);
+       }
+       return b->end_block - cblock;
+    }
+    return offset;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remap.h	Tue Sep 17 10:47:02 2002 +0000
@@ -0,0 +1,13 @@
+#ifndef __REMAP__H
+#define __REMAP__H
+typedef struct block_s block_t;
+
+typedef struct remap_s remap_t;
+
+remap_t* remap_loadmap( char *title);
+
+unsigned long remap_block( 
+	remap_t *map, int domain, int title, int program, 
+	unsigned long cblock, unsigned long offset);
+
+#endif