0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

TOOLS: remove useless crap

Most of the scripts in TOOLS seem entirely useless. Remove them.
There were about 3 types of scripts:
- apparent developer tools (like file format dumpers, benchmarks)
  => I doubt any mplayer developer still alive even uses these
- helpers for encoding or ripping stuff
  => mencoder is gone, at least from this version of mplayer
- helpers meant for users (launching mplayer in weird ways, etc.)
  => just no, it will cause you more pain than gain
So no, there is nothing useful.

Under the scripts not deleted, these are needed for building mplayer:
  file2string.py
  matroska.py
  vdpau_functions.py
These might have _some_ use (but still questionable):
  binary_codecs.sh
  checktree.sh
This commit is contained in:
wm4 2012-07-28 18:00:33 +02:00
parent 7d4576cf79
commit 6dc1249625
31 changed files with 0 additions and 5245 deletions

View File

@ -1,477 +0,0 @@
README for the TOOLS directory
==============================
Preamble
--------
In this directory you can find some nice scripts and code that makes
using MPlayer easier.
FIXME: Document the following tools:
bmovl-test
MPlayer scripts in the TOOLS dir
--------------------------------
edgedetect.fp, emboss.fp
Author: Reimar Döffinger
Description: Examples of custom fragment program for OpenGL video out driver
Usage: mplayer -vo gl:yuv=4:customprog=edgedetect.fp
midentify.sh
Author: Tobias Diedrich
Description: Runs 'mplayer -identify' for all arguments while preventing
video window flashing.
Usage: midentify.sh file1 [file2 ...]
mpconsole.sh
Author: Rich Felker
Description: Script to run MPlayer on the console (fbdev/mga_vid/etc.) without
the console text and/or flashing cursor getting in the way.
Usage: mpconsole.sh [mplayer options]
mplmult.sh
Author: Reimar Döffinger
Description: Example how to output video on multiple windows in sync. Might
be even more useful in combination with -vo ggi to distribute
the video arbitrarily.
Usage: mplmult.sh <n> <options>
n Number of MPlayer instances that display the video.
options Any options you would pass to MPlayer, more than
one file will usually not work.
subsearch.sh
Author: Alex Beregszaszi
Description: Collects subtitle files from the directory given as argument
('.' if none is given) and its subdirectories and prints
them as a comma separated list to stdout.
Usage: subsearch.sh [directory]
mplayer -sub `subsearch.sh` movie
wma2ogg.pl
Author: Peter Simon
Description: Converts WMA files to Ogg or MP3.
Usage: wma2ogg [options] <-f FILE1 | -f FILE2 ... | -a>
-f, -file filename
-a converts all WMA files in the current directory
-t output filetype (ogg, mp3) [default=ogg]
-lame I wanna use L.A.M.E. sure enough!
-br bitrate (kb/s) [default=from the WMA]
-del remove WMA file(s) after the transcoding
Tech scripts in the TOOLS dir
-----------------------------
calcbpp.pl
Author: Moritz Bunkus
Description: A script that calculates the $bpp for a movie, mentioned in
DOCS/tech/encoding-tips.txt, see that document for more info.
Usage: calcbpp.pl <resolution> <aspect ratio> <bitrate> <fps>
resolution: the cropped but unscaled resolution
(use '-vf cropdetect')
aspect ratio: the encoded aspect ratio. All DVDs come at
720x576 but contain a flag that tells the player
wether it should display the DVD at an aspect
ratio of 4/3 (1.333) or at 16/9 (1.777). Have a
look at MPlayer's output - there's something
about 'prescaling'. That's what you are looking
for.
bitrate: the video bitrate in kbit/s
fps: the fps
example: calcbpp.pl 720x440 16/9 896 25
countquant.pl
Author: Moritz Bunkus
Description: Counts the quantizers used for the encoding, mentioned in
DOCS/tech/encoding-tips.txt, see that document for more info.
Usage: countquant.pl < divx2pass.log
It will print out which quantizer was used how often. If you see
that e.g. the lowest quantizer (vqmin=2) gets used for > 95% of
the frames then you can safely increase your picture size.
plotpsnr.pl
Author: Jonas Jermann
Description: Draw PSNR log graphs using gnuplot.
Usage: plotpsnr.pl [options] <file>
-h, --help Display this help message
-quant Display quantizers
-size Display size
-psnr Display PSNR
-iframes Display I-frames
-pframes Display P-frames
-bframes Display B-frames
-aframes Display all frames in different colors
-cmp <file2> Compare two files
-qs <style> Quantizer style
-ss <style> Size style
-ps <style> PSNR style
Default: -quant -size -psnr -qs "p" -ss "i" -ps "p"
Note: Requires gnuplot. Comparison is based on file2. Comparison
assumes that the frame numbers of both files fit.
psnr-video.sh
Author: Matthias Wieser
Description: Calculates the PSNR between two existing video files.
The PSNR is calculated frame by frame.
Also prints the overall PSNR.
The script can be used to:
* Compare different softwarescalers (should I use
-sws 1 or -sws 2 ?)
* Compare different resolutions (is it better to scale
down to 640x360 or to 560x320)
* Compare different deinterlacers
* Compare different video codecs
* Compare video filters (is it better to use -vf hqdn3d
or lavcopts:nr=400)
* [...]
Usage: psnr-video.sh <file1> <file2> [<frames>] [<options1>] [<options2>]
<file1> and <file2> are the video files for which the PSNR
should be calculated.
[<frames>] is the number of frames to process, starting
from frame 1.
[<options1>] are additional MPlayer options for <file1>
[<options2>] are additional MPlayer options for <file2>
A file called ./psnr.dat will be created with the following
content:
File;Y;Cb;Cr
00000001.ppm;34.23;39.54;40.06;35.426
00000002.ppm;33.03;38.71;39.26;34.271
00000003.ppm;33.45;38.91;39.28;34.655
00000004.ppm;32.72;38.69;38.85;33.972
[...]
00000247.ppm;35.55;40.84;42.15;36.785
PSNR:;35.9887
Note: This script relies on the the tool "pnmpsnr" for the
frame-by-frame PSNR calculation.
Be aware that psnr-video.sh needs a lot of temporary space
in /tmp/.
asfinfo
Author: Arpi
Description: a simple ASF header display program
Usage: asfinfo <filename.asf>
Note: Also see MPlayer's -identify option.
avi-fix
Author: Arpi
Description: A simple tool to fix chunk sizes in RIFF AVI files.
Usage: avi-fix [-fix] <badfile.avi>
Note: It does not check or fix the index. You can try to fix it with
ffmpeg -i ... -acodec copy -vcodec copy.
checktree.sh
Author: Ivo van Poorten
Description: Check the source tree for anomalies.
Usage: checktree.sh -help
Note: This script is meant for developers to check the current
source tree and/or the patches they are working on.
mphelp_check.py
Author: Uoti Urpala
Description: Check console message translations for common errors.
Usage: mphelp_check.py [--missing] <master file> <files to check>
Note: Compares MPlayer translation files against a master file and
reports conflicting arguments, extra strings not present in
the base file and (optionally) missing strings.
cpuinfo
Author: Jürgen Keil
Description: the prototype ../cpuinfo.c
Note: Used by configure to emulate /proc/cpuinfo on non-Linux systems.
dump_mp4
Author: Arpi
Description: MPEG4-ES stream inspector, dumps the stream startcodes.
fastmemcpybench
Author: Felix Bünemann
Description: benchmark/testbed for fastmemcpy stuff
Note: Also see fastmem.sh.
movinfo
Author: Arpi
Description: Show QuickTime MOV file structure.
Usage: movinfo <filename.mov>
vivodump
Author: Arpi
Description: Dump H.263 frame headers from VIVO files.
Usage: vivodump <input_file> <output_file>
Miscellaneous scripts in the TOOLS dir
--------------------------------------
subedit.pl
Author: Michael Klepikov
Description: A script for pipelined editing of subtitle files.
Usage: subedit.pl [switches]
-if,--input-format <fmt> input format; supported: SRT (default: SRT)
-of,--output-format <fmt> output format; supported: SRT
(default: input format)
-s,--shift <time> shift all subtitles by <time>
(format: [-]hh:mm:ss,fraction)
-c,--scale <time> scale by adding <time> to overall duration
-f,--split-from <time> drop subtitles that end before <time>
-t,--split-to <time> drop subtitles that start after <time> (will
truncate timing if it overlaps a boundary)
-r,--renumber renumber SRT subtitles in output
-d,--debug enable debug output
-h,--help help message
w32codec_dl.pl
Author: Tom Lees
Description: This script will use the Windows Media Player codec download
infrastructure to aquire the codecs listed in codecs.conf and put
them in a directory named "codecs/" below the current directory.
Usage: w32codec_dl.pl <codecs.conf location>
Note: You will need the libwww-perl stuff and the cabextract utility
which can be found at http://www.kyz.uklinux.net/cabextract.php3.
binary_codecs.sh
Author: Andrea Menucci, thuglife
Description: Downloads binary codecs from mplayerhq.hu and installs them
on a Debian system.
Usage: binary_codecs.sh install
binary_codecs.sh uninstall
vobshift.py
Author: Gábor Farkas
Description: Adjust the time-info in vobsub files
Usage: vobshift.py in.idx out.idx +8.3
Will shift the time by 8.3 seconds
subrip.c
Author: Kim Minh Kaplan
Description: Transform VOBsub subtitles into Subrip text subtitles using
GOCR/JOCR.
Usage: subrip <vobsub basename> [subid [output filename] ]
Note: Requires at least JOCR/GOCR 0.37.
You will have to change the 'vobsub_id' value if you want a
subtitle different from number 0. Hint: You can view the
subtitle that is being decoded with "display subtitle-*.pgm".
alaw-gen.c
Author: Arpi
Description: Generates alaw/ulaw tables.
Note: Created to work around a past license issue, no longer useful.
avisubdump.c
Author: Tobias Diedrich
Description: Dumps vobsub soft subtitles streams embedded in AVI files.
Usage: avisubdump <movie.avi>
vfw2menc.c
Author: Gianluigi Tiesi
Description: Creates a codec settings file from the Video for Windows codecs
found in the mplayer codec packs.
Usage: vfw2menc -f <fourcc> -d <codec.dll> -s <settingsfile.mcf>
-h|--help - displays this help
-d|--driver filename - dll or drv to load
-f|--fourcc fourcc - fourcc of selected driver
-s|--save filename - save settings to file
-c|--check filename - load and show setting in filename
-v|--view - displays the config dialog and do nothing
Notes: Works on Windows/Linux x86 only.
modify_reg.c
Author: Alan Nisota
Description: Modifies registry file (usually ~/.mplayer/registry)
Usage: modify_reg -r <registry_file> -l
modify_reg -r <registry_file> -k <key> [-d|-v <value>[-t <type>]]
-r|--registry - path to registry file
-l|--list - shows all keys and values
-k|--key - registry key
-d|--del - delete key
-v|--value - new value for key
-t|--type - key type: string (default) or dword
Notes: Necessary to use CoreAVC with MPlayer
compare.c
Author: Michael Niedermayer
Description: Simple file compare program that detects the number of rounding
errors and dies if the error is too large.
Usage: compare <file1> <file2>
realcodecs/
Author: miscellaneous
Description: Wrappers for Linux Real binary codecs used to analyze, alter and
dump the data flow between RealPlayer and its codecs.
Usage: - Set the path to the RealPlayer codecs directory in the C files.
- Run 'make realcodecs'.
- Rename the original codecs to match the names expected in the
wrapper sources. The default is to give them a "real" prefix,
e.g. realcook.so.6.0.
- Put the wrappers in the RealPlayer codecs directory.
Notes: Known to work at least on Linux x86 with RealPlayer8.
netstream - access remote streams
---------------------------------
netstream allows you to access most MPlayer stream types from a remote host.
The main purpose of this feature is to make it possible to directly use the
CD or DVD drive of another computer on the network (provided you have the
required bandwidth). On the downside some stream types (currently TV and MF)
are not usable remotely because they are implemented at the demuxer level.
Be aware that currently the server is not secure at all.
Compile the server by running 'make TOOLS/netstream' ('make TOOLS/netstream.exe'
on windows) from the root of mplayer source and then copy the netstream binary
to the right place on your system (usually /usr/local/bin on Unix). Start the
netstream server on the computer you intend to access remotely. There are no
command line arguments.
Play the second track of a VCD on the server with:
mplayer -cache 5000 mpst://servername/vcd://2
Access files on this server with:
mplayer -cache 5000 mpst://servername//usr/local/movies/lol.avi
Note that paths which do not start with a / will be interpreted as relative to
the directory where the server is running. The '-cache' option is not needed
but highly recommended.
netstream will not take -dvd-device, so you must either symlink
your drive to /dev/dvd/ or use the dvd:///path/to/dvd.
for example: mpst://audioserver/dvd:////dev/optical/lg_black_dvd

View File

@ -1,68 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
// sox -t raw -A -r 8000 -b alaw.alaw -t sw alaw.out
int main(void){
int i;
FILE *f;
f=fopen("alaw.dat","wb");
for(i=0;i<256;i++) fwrite(&i,1,1,f);
fclose(f);
system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");
printf("// Generated by TOOLS/alaw-gen.c\n\n");
printf("#ifndef MPLAYER_ALAW_H\n");
printf("#define MPLAYER_ALAW_H\n");
printf("\nconst short alaw2short[]={\n");
f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
signed short x;
fread(&x,2,1,f);
printf("%7d",x);
if(i!=255) putchar(',');
if((i&7)==7) printf("\n");
}
fclose(f);
printf("};\n");
system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");
printf("\nconst short ulaw2short[]={\n");
f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
signed short x;
fread(&x,2,1,f);
printf("%7d",x);
if(i!=255) putchar(',');
if((i&7)==7) printf("\n");
}
fclose(f);
printf("};\n\n");
printf("#endif /* MPLAYER_ALAW_H */\n");
return 0;
}

View File

@ -1,289 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define SAVE_STREAMS
// simple ASF header display program by A'rpi/ESP-team
// .asf fileformat docs from http://divx.euro.ru
#include <stdio.h>
#include <stdlib.h>
typedef struct __attribute__((packed))
{
long biSize; // sizeof(BITMAPINFOHEADER)
long biWidth;
long biHeight;
short biPlanes; // unused
short biBitCount;
long biCompression; // fourcc of image
long biSizeImage; // size of image. For uncompressed images
// ( biCompression 0 or 3 ) can be zero.
long biXPelsPerMeter; // unused
long biYPelsPerMeter; // unused
long biClrUsed; // valid only for palettized images.
// Number of colors in palette.
long biClrImportant;
} BITMAPINFOHEADER;
typedef struct
{
short wFormatTag; // value that identifies compression format
short nChannels;
long nSamplesPerSec;
long nAvgBytesPerSec;
short nBlockAlign; // size of a data sample
short wBitsPerSample;
short cbSize; // size of format-specific data
} WAVEFORMATEX;
typedef struct __attribute__((packed)) {
unsigned char guid[16];
unsigned long long size;
} ASF_obj_header_t;
typedef struct __attribute__((packed)) {
ASF_obj_header_t objh;
unsigned int cno; // number of subchunks
unsigned char v1; // unknown (0x01)
unsigned char v2; // unknown (0x02)
} ASF_header_t;
typedef struct __attribute__((packed)) {
unsigned char client[16]; // Client GUID
unsigned long long file_size;
unsigned long long creat_time; //File creation time FILETIME 8
unsigned long long packets; //Number of packets UINT64 8
unsigned long long end_timestamp; //Timestamp of the end position UINT64 8
unsigned long long duration; //Duration of the playback UINT64 8
unsigned long start_timestamp; //Timestamp of the start position UINT32 4
unsigned long unk1; //Unknown, maybe reserved ( usually contains 0 ) UINT32 4
unsigned long flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
unsigned long packetsize; //Size of packet, in bytes UINT32 4
unsigned long packetsize2; //Size of packet ( confirm ) UINT32 4
unsigned long frame_size; //Size of uncompressed video frame UINT32 4
} ASF_file_header_t;
typedef struct __attribute__((packed)) {
unsigned char type[16]; // Stream type (audio/video) GUID 16
unsigned char concealment[16]; // Audio error concealment type GUID 16
unsigned long long unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
unsigned long type_size; //Total size of type-specific data UINT32 4
unsigned long stream_size; //Size of stream-specific data UINT32 4
unsigned short stream_no; //Stream number UINT16 2
unsigned long unk2; //Unknown UINT32 4
} ASF_stream_header_t;
typedef struct __attribute__((packed)) {
unsigned char streamno;
unsigned char seq;
unsigned long x;
unsigned char flag;
} ASF_segmhdr_t;
ASF_header_t asfh;
ASF_obj_header_t objh;
ASF_file_header_t fileh;
ASF_stream_header_t streamh;
unsigned char buffer[8192];
int i;
static char* chunk_type(unsigned char* guid){
switch(*((unsigned int*)guid)){
case 0xF8699E40: return "guid_audio_stream";
case 0xBC19EFC0: return "guid_video_stream";
case 0x49f1a440: return "guid_audio_conceal_none";
case 0xbfc3cd50: return "guid_audio_conceal_interleave";
case 0x75B22630: return "guid_header";
case 0x75b22636: return "guid_data_chunk";
case 0x33000890: return "guid_index_chunk";
case 0xB7DC0791: return "guid_stream_header";
case 0xD6E229D1: return "guid_header_2_0";
case 0x8CABDCA1: return "guid_file_header";
}
return NULL;
}
static void print_wave_header(WAVEFORMATEX *h){
printf("======= WAVE Format =======\n");
printf("Format Tag: %d (0x%X)\n", h->wFormatTag, h->wFormatTag);
printf("Channels: %d\n", h->nChannels);
printf("Samplerate: %ld\n", h->nSamplesPerSec);
printf("avg byte/sec: %ld\n", h->nAvgBytesPerSec);
printf("Block align: %d\n", h->nBlockAlign);
printf("bits/sample: %d\n", h->wBitsPerSample);
printf("cbSize: %d\n", h->cbSize);
switch(h->wFormatTag){
case 0x01: printf("Audio in PCM format\n"); break;
case 0x50: printf("Audio in MPEG Layer 1/2 format\n"); break;
case 0x55: printf("Audio in MPEG Layer-3 format\n"); break; // ACM
case 0x02: printf("Audio in MS ADPCM format\n"); break; // ACM
case 0x11: printf("Audio in IMA ADPCM format\n"); break; // ACM
case 0x31:
case 0x32: printf("Audio in MS GSM 6.10 format\n"); break; // ACM
case 0x160:
case 0x161: printf("Audio in DivX WMA format\n"); break; // ACM
default: printf("Audio in UNKNOWN (id=0x%X) format\n", h->wFormatTag);
}
printf("===========================\n");
}
static void print_video_header(BITMAPINFOHEADER *h){
printf("======= VIDEO Format ======\n");
printf(" biSize %ld\n", h->biSize);
printf(" biWidth %ld\n", h->biWidth);
printf(" biHeight %ld\n", h->biHeight);
printf(" biPlanes %d\n", h->biPlanes);
printf(" biBitCount %d\n", h->biBitCount);
printf(" biCompression %ld='%.4s'\n", h->biCompression, (const char*)&h->biCompression);
printf(" biSizeImage %ld\n", h->biSizeImage);
printf("===========================\n");
}
FILE* streams[128];
int main(int argc, char* argv[]){
FILE *f = fopen(argc > 1 ? argv[1] : "Alice Deejay - Back In My Life.asf", "rb");
if(!f){
printf("file not found\n");
exit(1);
}
//printf("sizeof=%d\n", sizeof(objh));
//printf("sizeof=%d\n", sizeof(asfh));
fread(&asfh, sizeof(asfh), 1, f); // header obj
//for(i = 0; i < 16; i++)
// printf("%02X ", asfh.objh.guid[i]);
printf("[%s] %d (subchunks: %d)\n", chunk_type(asfh.objh.guid),
(int) asfh.objh.size, asfh.cno);
while(fread(&objh, sizeof(objh), 1, f) > 0){
int pos = ftell(f);
//for(i = 0; i < 16; i++)
// printf("%02X ", objh.guid[i]);
printf("0x%08X [%s] %d\n", pos-sizeof(objh), chunk_type(objh.guid),
(int) objh.size);
switch(*((unsigned int*)&objh.guid)){
case 0xB7DC0791: // guid_stream_header
fread(&streamh, sizeof(streamh), 1, f);
printf("stream type: %s\n", chunk_type(streamh.type));
printf("stream concealment: %s\n", chunk_type(streamh.concealment));
printf("type: %d bytes, stream: %d bytes ID: %d\n",
(int)streamh.type_size, (int)streamh.stream_size,
(int)streamh.stream_no);
printf("FILEPOS=0x%lX\n", ftell(f));
// type-specific data:
fread(buffer,streamh.type_size,1,f);
switch(*((unsigned int*)&streamh.type)){
case 0xF8699E40: // guid_audio_stream
print_wave_header((WAVEFORMATEX*)buffer);
break;
case 0xBC19EFC0: // guid_video_stream
print_video_header((BITMAPINFOHEADER*)&buffer[4 + 4 + 1 + 2]);
break;
}
// stream-specific data:
fread(buffer, streamh.stream_size, 1, f);
break;
//case 0xD6E229D1:
// return "guid_header_2_0";
case 0x8CABDCA1: // guid_file_header
fread(&fileh, sizeof(fileh), 1, f);
printf("packets: %d flags: %d pack_size: %d frame_size: %d\n",
(int)fileh.packets, (int)fileh.flags, (int)fileh.packetsize,
(int)fileh.frame_size);
break;
case 0x75b22636: // guid_data_chunk
{ int endp = pos + objh.size - sizeof(objh);
unsigned char* packet = malloc((int)fileh.packetsize);
int fpos;
fseek(f, 26, SEEK_CUR);
while((fpos = ftell(f)) < endp){
fread(packet, (int)fileh.packetsize, 1, f);
if(packet[0] == 0x82){
unsigned char flags = packet[3];
unsigned char* p = &packet[5];
unsigned long time;
unsigned short duration;
int segs = 1;
int seg;
int padding=0;
if(flags & 8){
padding = p[0];
++p;
} else
if(flags & 16){
padding = p[0] | (p[1] << 8);
p += 2;
}
time = *((unsigned long*)p);
p += 4;
duration = *((unsigned short*)p);
p += 2;
if(flags & 1){
segs = p[0] - 0x80;
++p;
}
printf("%08X: flag=%02X segs=%d pad=%d time=%ld dur=%d\n",
fpos, flags, segs, padding, time, duration);
for(seg = 0; seg < segs; seg++){
ASF_segmhdr_t* sh = (ASF_segmhdr_t*)p;
int len = 0;
p += sizeof(ASF_segmhdr_t);
if(sh->flag & 8) p+=8;// else
if(sh->flag & 1) ++p;
if(flags & 1){
len = *((unsigned short*)p);
p += 2;
}
printf(" seg #%d: streamno=%d seq=%d flag=%02X len=%d\n",
seg, sh->streamno&0x7F, sh->seq, sh->flag, len);
#ifdef SAVE_STREAMS
if(!streams[sh->streamno & 0x7F]){
char name[256];
snprintf(name, 256, "stream%02X.dat", sh->streamno & 0x7F);
streams[sh->streamno & 0x7F] = fopen(name, "wb");
}
fwrite(p, len, 1, streams[sh->streamno & 0x7F]);
#endif
p += len;
}
} else
printf("%08X: UNKNOWN %02X %02X %02X %02X %02X...\n", fpos,
packet[0], packet[1], packet[2], packet[3], packet[4]);
}
}
break;
//case 0x33000890:
// return "guid_index_chunk";
}
fseek(f, pos + objh.size - sizeof(objh), SEEK_SET);
}
fclose(f);
return 0;
}

View File

@ -1,158 +0,0 @@
/* avi-fix v0.1 (C) A'rpi
* simple tool to fix chunk sizes in a RIFF AVI file
* it doesn't check/fix index. You can try to fix it with ffmpeg -i ... -acodec
* copy -vcodec copy
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#ifdef MP_DEBUG
#define mp_debug(...) printf(__VA_ARGS__)
#else
#define mp_debug(...)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
static inline char xx(unsigned char c){
if(c>=32 && c<128) return c;
return '?';
}
static inline unsigned int getid(FILE* f){
unsigned int id;
id=fgetc(f);
id=(id<<8)|fgetc(f);
id=(id<<8)|fgetc(f);
id=(id<<8)|fgetc(f);
return id;
}
int main(int argc,char* argv[]){
//FILE* f=fopen("edgar.avi","rb"); // readonly (report errors)
//FILE* f=fopen("edgar.avi","rb+"); // fix mode (fix chunk sizes)
unsigned int lastgood=0;
unsigned int fixat=0;
unsigned int offset=0;
int fix_flag=0;
FILE* f;
if(argc<=1){
printf("Usage: %s [-fix] badfile.avi\n",argv[0]);
exit(1);
}
if(!strcmp(argv[1],"-fix")){
fix_flag=1;
f=fopen(argv[argc-1],"rb+");
} else
f=fopen(argv[argc-1],"rb");
if(!f){
perror("error");
printf("couldnt open '%s'\n",argv[argc-1]);
exit(2);
}
while(1){
unsigned int id,len;
again:
id=fgetc(f);
id=(id<<8)|fgetc(f);
id=(id<<8)|fgetc(f);
faszom:
if(feof(f)) break;
// if(!lastgood && feof(f)) break;
id=(id<<8)|fgetc(f);
// lastgood=ftell(f);
mp_debug("%08X: %c%c%c%c\n",(int)ftell(f)-4,xx(id>>24),xx(id>>16),xx(id>>8),xx(id));
switch(id){
case FCC('R','I','F','F'):
fread(&len,4,1,f); // filesize
id=getid(f); // AVI
mp_debug("RIFF header, filesize=0x%X format=%c%c%c%c\n",len,xx(id>>24),xx(id>>16),xx(id>>8),xx(id));
break;
case FCC('L','I','S','T'):
fread(&len,4,1,f); // size
id=getid(f); // AVI
mp_debug("LIST size=0x%X format=%c%c%c%c\n",len,xx(id>>24),xx(id>>16),xx(id>>8),xx(id));
//case FCC('h','d','r','l'):
//case FCC('s','t','r','l'):
//case FCC('o','d','m','l'):
//case FCC('m','o','v','i'):
break;
// legal chunk IDs:
case FCC('a','v','i','h'): // avi header
case FCC('s','t','r','h'): // stream header
case FCC('s','t','r','f'): // stream format
case FCC('J','U','N','K'): // official shit
// index:
case FCC('i','d','x','1'): // main index??
case FCC('d','m','l','h'): // opendml header
case FCC('i','n','d','x'): // opendml main index??
case FCC('i','x','0','0'): // opendml sub index??
case FCC('i','x','0','1'): // opendml sub index??
// data:
case FCC('0','1','w','b'): // audio track #1
case FCC('0','2','w','b'): // audio track #2
case FCC('0','3','w','b'): // audio track #3
case FCC('0','0','d','b'): // uncompressed video
case FCC('0','0','d','c'): // compressed video
case FCC('0','0','_','_'): // A-V interleaved (type2 DV file)
// info:
case FCC('I','S','F','T'): // INFO: software
case FCC('I','S','R','C'): // INFO: source
case FCC('I','N','A','M'): // INFO: name
case FCC('I','S','B','J'): // INFO: subject
case FCC('I','A','R','T'): // INFO: artist
case FCC('I','C','O','P'): // INFO: copyright
case FCC('I','C','M','T'): // INFO: comment
lastgood=ftell(f);
if(fixat && fix_flag){
// fix last chunk's size field:
fseek(f,fixat,SEEK_SET);
len=lastgood-fixat-8;
mp_debug("Correct len to 0x%X\n",len);
fwrite(&len,4,1,f);
fseek(f,lastgood,SEEK_SET);
fixat=0;
}
fread(&len,4,1,f); // size
mp_debug("ID ok, chunk len=0x%X\n",len);
len+=len&1; // align at 2
fseek(f,len,SEEK_CUR); // skip data
break;
default:
if(!lastgood){
++offset;
mp_debug("invalid ID, trying %d byte offset\n",offset);
goto faszom; // try again @ next post
}
mp_debug("invalid ID, parsing next chunk's data at 0x%X\n",lastgood);
fseek(f,lastgood,SEEK_SET);
fixat=lastgood;
lastgood=0;
goto again;
}
offset=0;
}
return 0;
}

View File

@ -1,200 +0,0 @@
/*
* avisubdump
*
* avi vobsub subtitle stream dumper (c) 2004 Tobias Diedrich
*
* The subtitles are dumped to stdout.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#define FCC(a,b,c,d) (((a))|((b)<<8)|((c)<<16)|((d)<<24))
#define FCC_RIFF FCC('R','I','F','F')
#define FCC_LIST FCC('L','I','S','T')
#define FCC_strh FCC('s','t','r','h')
#define FCC_txts FCC('t','x','t','s')
#define FCC_GAB2 FCC('G','A','B','2')
#define GAB_LANGUAGE 0
#define GAB_ENTRY 1
#define GAB_LANGUAGE_UNICODE 2
#define GAB_ENTRY_UNICODE 3
#define GAB_RAWTEXTSUBTITLE 4
static unsigned int getle16(FILE* f){
unsigned int res;
res = fgetc(f);
res |= fgetc(f) << 8;
return res;
}
static unsigned int getle(FILE* f){
unsigned int res;
res = fgetc(f);
res |= fgetc(f) << 8;
res |= fgetc(f) << 16;
res |= fgetc(f) << 24;
return res;
}
static void skip(FILE *f, int len)
{
if (f != stdin) {
fseek(f,len,SEEK_CUR);
} else {
void *buf = malloc(len);
fread(buf,len,1,f);
free(buf);
}
}
static int stream_id(unsigned int id)
{
char c1,c2;
c1 = (char)(id & 0xff);
c2 = (char)((id >> 8) & 0xff);
if (c1 >= '0' && c1 <= '9' &&
c2 >= '0' && c2 <= '9') {
c1 -= '0';
c2 -= '0';
return c1*10+c2;
}
return -1;
}
static int dumpsub_gab2(FILE *f, int size) {
int ret = 0;
while (ret + 6 <= size) {
unsigned int len, id;
char *buf;
int i;
id = getle16(f); ret += 2;
len = getle(f); ret += 4;
if (ret + len > size) break;
buf = malloc(len);
ret += fread(buf, 1, len, f);
switch (id) {
case GAB_LANGUAGE_UNICODE: /* FIXME: convert to utf-8; endianness */
for (i=0; i<len; i++) buf[i] = buf[i*2];
case GAB_LANGUAGE:
fprintf(stderr, "LANGUAGE: %s\n", buf);
break;
case GAB_ENTRY_UNICODE: /* FIXME: convert to utf-8; endianness */
for (i=0; i<len; i++) buf[i] = buf[i*2];
case GAB_ENTRY:
fprintf(stderr, "ENTRY: %s\n", buf);
break;
case GAB_RAWTEXTSUBTITLE:
printf("%s", buf);
break;
default:
fprintf(stderr, "Unknown type %d, len %d\n", id, len);
break;
}
free(buf);
}
return ret;
}
static void dump(FILE *f) {
unsigned int id, len;
int stream = 0;
int substream = -2;
while (1) {
id = getle(f);
len = getle(f);
if(feof(f)) break;
if (id == FCC_RIFF ||
id == FCC_LIST) {
getle(f);
continue;
} else if (id == FCC_strh) {
id = getle(f); len -= 4;
fprintf(stderr, "Stream %d is %c%c%c%c",
stream,
id,
id >> 8,
id >> 16,
id >> 24);
if (id == FCC_txts) {
substream = stream;
fprintf(stderr, " (subtitle stream)");
}
fprintf(stderr, ".\n");
stream++;
} else if (stream_id(id) == substream) {
unsigned int subid;
subid = getle(f); len -= 4;
if (subid != FCC_GAB2) {
fprintf(stderr,
"Unknown subtitle chunk %c%c%c%c (%08x).\n",
id, id >> 8, id >> 16, id >> 24, subid);
} else {
skip(f,1); len -= 1;
len -= dumpsub_gab2(f, len);
}
}
len+=len&1;
skip(f,len);
}
}
int main(int argc,char* argv[])
{
FILE* f;
if (argc != 2) {
fprintf(stderr, "Usage: %s <avi>\n", argv[0]);
exit(1);
}
if (strcmp(argv[argc-1], "-") == 0) {
dump(stdin);
return 0;
}
f=fopen(argv[argc-1],"rb");
if (!f) {
fprintf(stderr, "Could not open '%s': %s\n",
argv[argc-1], strerror(errno));
exit(-errno);
}
dump(f);
fclose(f);
return 0;
}

View File

@ -1,136 +0,0 @@
/* small program to test the features of vf_bmovl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#define DEBUG 0
static void
blit(int fifo, unsigned char *bitmap, int width, int height,
int xpos, int ypos, int alpha, int clear)
{
char str[100];
int nbytes;
sprintf(str, "RGBA32 %d %d %d %d %d %d\n",
width, height, xpos, ypos, alpha, clear);
if(DEBUG) printf("Sending %s", str);
write(fifo, str, strlen(str));
nbytes = write(fifo, bitmap, width*height*4);
if(DEBUG) printf("Sent %d bytes of bitmap data...\n", nbytes);
}
static void
set_alpha(int fifo, int width, int height, int xpos, int ypos, int alpha) {
char str[100];
sprintf(str, "ALPHA %d %d %d %d %d\n",
width, height, xpos, ypos, alpha);
if(DEBUG) printf("Sending %s", str);
write(fifo, str, strlen(str));
}
static void
paint(unsigned char* bitmap, int size, int red, int green, int blue, int alpha) {
int i;
for(i=0; i < size; i+=4) {
bitmap[i+0] = red;
bitmap[i+1] = green;
bitmap[i+2] = blue;
bitmap[i+3] = alpha;
}
}
int main(int argc, char **argv) {
int fifo=-1;
int width=0, height=0;
unsigned char *bitmap;
SDL_Surface *image;
int i;
if(argc<3) {
printf("Usage: %s <bmovl fifo> <image file> <width> <height>\n", argv[0]);
printf("width and height are w/h of MPlayer's screen!\n");
exit(10);
}
width = atoi(argv[3]);
height = atoi(argv[4]);
fifo = open( argv[1], O_RDWR );
if(!fifo) {
fprintf(stderr, "Error opening FIFO %s!\n", argv[1]);
exit(10);
}
image = IMG_Load(argv[2]);
if(!image) {
fprintf(stderr, "Couldn't load image %s!\n", argv[2]);
exit(10);
}
printf("Loaded image %s: width=%d, height=%d\n", argv[2], image->w, image->h);
// Display and move image
for(i=0; (i < (width - image->w)) && (i < (height - image->h)); i += 5)
blit(fifo, image->pixels, image->w, image->h, i, i, 0, 1);
// Create a 75x75 bitmap
bitmap = malloc(75 * 75 * 4);
// Paint bitmap red, 50% transparent and blit at position 50,50
paint(bitmap, (75*75*4), 255, 0, 0, 128);
blit(fifo, bitmap, 75, 75, 50, 50, 0, 0);
// Paint bitmap green, 50% transparent and blit at position -50,50
paint(bitmap, (75*75*4), 0, 255, 0, 128);
blit(fifo, bitmap, 75, 75, width-50-75, 50, 0, 0);
// Paint bitmap blue, 50% transparent and blit at position -50,50
paint(bitmap, (75*75*4), 0, 0, 255, 128);
blit(fifo, bitmap, 75, 75, 50, height-50-75, 0, 0);
// Blit another image in the middle, completly transparent
blit(fifo, image->pixels, image->w, image->h,
(width/2)-(image->w/2), (height/2)-(image->h/2), -255, 0);
// Fade in image
for(i=-255; i <= 0; i++)
set_alpha(fifo, image->w, image->h,
(width/2)-(image->w/2), (height/2)-(image->h/2), i);
// Clean up
free(bitmap);
SDL_FreeSurface(image);
return 0;
}

View File

@ -1,43 +0,0 @@
#!/usr/bin/perl -w
use POSIX;
sub round {
my $v = shift;
return floor($v + 0.5);
}
$raw_aspect = 720/576;
if (scalar(@ARGV) < 4) {
print("Please provide a) the cropped but unscaled resolution (e.g. " .
"716x524), b) the aspect ratio (either 4/3 or 16/9 for most DVDs), " .
"c) the video bitrate in kbps (e.g. 800) and d) the movie's fps.\n");
print("If your DVD is not encoded at 720x576 then change the \$raw_aspect" .
"variable at the beginning of this script.\n");
exit(1);
}
($unscaled_width, $unscaled_height) = split('x', $ARGV[0]);
$encoded_at = $ARGV[1];
if ($encoded_at =~ /\//) {
my @a = split(/\//, $encoded_at);
$encoded_at = $a[0] / $a[1];
}
$scaled_width = $unscaled_width * ($encoded_at / ($raw_aspect));
$scaled_height = $unscaled_height;
$picture_ar = $scaled_width / $scaled_height;
($bps, $fps) = @ARGV[2, 3];
printf("Prescaled picture: %dx%d, AR %.2f\n", $scaled_width, $scaled_height,
$picture_ar);
for ($width = 720; $width >= 320; $width -= 16) {
$height = 16 * round($width / $picture_ar / 16);
$diff = round($width / $picture_ar - $height);
$new_ar = $width / $height;
$picture_ar_error = abs(100 - $picture_ar / $new_ar * 100);
printf("${width}x${height}, diff % 3d, new AR %.2f, AR error %.2f%% " .
"scale=%d:%d bpp: %.3f\n", $diff, $new_ar, $picture_ar_error, $width,
$height, ($bps * 1000) / ($width * $height * $fps));
}

View File

@ -1,73 +0,0 @@
/*
* Simple file compare program, it finds the number of rounding errors
* and dies if there is too large an error ( ABS(a-b)>1 ).
*
* copyright (c) 2001 Michael Niedermayer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
// FIXME: No checks but it is just for debugging so who cares ;)
int main(int argc, char **argv)
{
FILE *f0, *f1;
int dif=0;
if(argc!=3)
{
printf("compare <file1> <file2>\n");
exit(2);
}
f0= fopen(argv[1], "rb");
f1= fopen(argv[2], "rb");
for(;;)
{
short c0;
short c1;
int d;
int e0= fread(&c0, 2, 1, f0);
int e1= fread(&c1, 2, 1, f1);
d=c0-c1;
if(e0==0 && e1==0) break;
if(e0==0 || e1==0)
{
printf("FATAL error, files have different size!\n");
exit(1);
}
if(d<0) d=-d; // ABS
if(d>1)
{
printf("FATAL error, too large a difference found (%d)!\n", d);
exit(1);
}
if(d) dif++;
}
fclose(f0);
fclose(f1);
printf("%d (+/-1)differences found\n", dif);
exit(0);
}

View File

@ -1,35 +0,0 @@
#!/usr/bin/perl -w
sub display_quants {
$frames = 0;
foreach $key (sort(keys(%quants))) {
$frames += $quants{$key};
}
foreach $key (sort({ $a <=> $b } keys(%quants))) {
printf("q=%d:\t% 6d, % 6.2f%%\n", $key, $quants{$key}, $quants{$key} *
100 / $frames);
}
print("$lines lines processed, $frames frames found\n");
printf("average quant. is: %f\n", $quant_total/$frames);
}
$lines = 0;
$thislines = 0;
$quant_total = 0;
while (<STDIN>) {
$lines++;
$thislines++;
if (/ q:([0-9]+) /) {
$quants{$1}++;
} elsif (/ q:(([0-9]+)\.[0-9]+) /) {
$quants{$2}++;
$quant_total += $1;
}
if ((scalar(@ARGV) > 0) && ($thislines > $ARGV[0])) {
display_quants();
$thislines = 0;
}
}
display_quants();

View File

@ -1,63 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
int main(void){
int c;
unsigned int head=-1;
int pos=-3;
while((c=getchar())>=0){
head<<=8;
if(head==0x100){
int startcode=head|c;
printf("%08X 1%02X ",pos,c);
if (startcode<=0x11F) printf("Video Object Start");
else if(startcode<=0x12F) printf("Video Object Layer Start");
else if(startcode<=0x13F) printf("Reserved");
else if(startcode<=0x15F) printf("FGS bp start");
else if(startcode<=0x1AF) printf("Reserved");
else if(startcode==0x1B0) printf("Visual Object Seq Start");
else if(startcode==0x1B1) printf("Visual Object Seq End");
else if(startcode==0x1B2) printf("User Data");
else if(startcode==0x1B3) printf("Group of VOP start");
else if(startcode==0x1B4) printf("Video Session Error");
else if(startcode==0x1B5) printf("Visual Object Start");
else if(startcode==0x1B6) printf("Video Object Plane start");
else if(startcode==0x1B7) printf("slice start");
else if(startcode==0x1B8) printf("extension start");
else if(startcode==0x1B9) printf("fgs start");
else if(startcode==0x1BA) printf("FBA Object start");
else if(startcode==0x1BB) printf("FBA Object Plane start");
else if(startcode==0x1BC) printf("Mesh Object start");
else if(startcode==0x1BD) printf("Mesh Object Plane start");
else if(startcode==0x1BE) printf("Still Textutre Object start");
else if(startcode==0x1BF) printf("Textutre Spatial Layer start");
else if(startcode==0x1C0) printf("Textutre SNR Layer start");
else if(startcode==0x1C1) printf("Textutre Tile start");
else if(startcode==0x1C2) printf("Textutre Shape Layer start");
else if(startcode==0x1C3) printf("stuffing start");
else if(startcode<=0x1C5) printf("reserved");
else if(startcode<=0x1FF) printf("System start");
printf("\n");
}
head|=c;
++pos;
}
return 0;
}

View File

@ -1,37 +0,0 @@
!!ARBfp1.0
# Custom YUV->RGB conversion program for MPlayer's -vo gl.
# Copyleft (C) Reimar Döffinger, 2005
# Licensed under the GNU GPL v2 or later
# Usage: mplayer -vo gl:yuv=4:customprog=edgedetect.fp
# This is some custom edge-detect like effect.
# Try adjusting the gamma!
# program.env[0].xy contains the size of one source texel
TEMP res, yuv, pos, tmp, sizes;
SWZ sizes, program.env[0], x, y, 0, 0;
TEX yuv.r, fragment.texcoord[0], texture[0], 2D;
ADD pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the right and below
TEX tmp.r, pos.xyxy, texture[0], 2D;
MAD yuv.r, yuv.rrrr, {4}, -tmp.rrrr;
TEX tmp.r, pos.zwzw, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
SUB pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the left and above
TEX tmp.r, pos.xyxy, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
TEX tmp.r, pos.zwzw, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
TEX yuv.g, fragment.texcoord[1], texture[1], 2D;
TEX yuv.b, fragment.texcoord[2], texture[2], 2D;
# now do the normal YUV -> RGB conversion but include effect strength
# multiplication by 2 and 0.5 offset
MAD res, yuv.rrrr, {2.328, 2.328, 2.328, 0}, {-0.37416, 1.03133, -0.58599, 0.125};
MAD res.rgb, yuv.gggg, {0, -0.391, 2.018, 0}, res;
MAD res.rgb, yuv.bbbb, {1.596, -0.813, 0, 0}, res;
# do gamma texture lookup
TEX res.r, res.raaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.g, res.gaaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.b, res.baaa, texture[3], 2D;
# move res into result, this allows easily commenting out some parts.
MOV result.color, res;
END

View File

@ -1,38 +0,0 @@
!!ARBfp1.0
# Custom YUV->RGB conversion program for MPlayer's -vo gl.
# Copyleft (C) Reimar Döffinger, 2005
# Licensed under the GNU GPL v2 or later
# Usage: mplayer -vo gl:yuv=4:customprog=edgeenh.fp
# This is some custom edge-enhancement like effect.
# Try adjusting the gamma!
# program.env[0].xy contains the size of one source texel
PARAM strength = {0.5};
TEMP res, yuv, pos, tmp, sizes, center;
SWZ sizes, program.env[0], x, y, 0, 0;
TEX center.r, fragment.texcoord[0], texture[0], 2D;
ADD pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the right and below
TEX tmp.r, pos.xyxy, texture[0], 2D;
MAD yuv.r, center.rrrr, {4}, -tmp.rrrr;
TEX tmp.r, pos.zwzw, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
SUB pos, fragment.texcoord[0].xyxy, sizes.xwwy; # texels to the left and above
TEX tmp.r, pos.xyxy, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
TEX tmp.r, pos.zwzw, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
MAD yuv.r, yuv.rrrr, strength, center.rrrr;
TEX yuv.g, fragment.texcoord[1], texture[1], 2D;
TEX yuv.b, fragment.texcoord[2], texture[2], 2D;
# now do the normal YUV -> RGB conversion
MAD res, yuv.rrrr, {1.164, 1.164, 1.164, 0}, {-0.87416, 0.53133, -1.08599, 0.125};
MAD res.rgb, yuv.gggg, {0, -0.391, 2.018, 0}, res;
MAD res.rgb, yuv.bbbb, {1.596, -0.813, 0, 0}, res;
# do gamma texture lookup
TEX res.r, res.raaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.g, res.gaaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.b, res.baaa, texture[3], 2D;
# move res into result, this allows easily commenting out some parts.
MOV result.color, res;
END

View File

@ -1,29 +0,0 @@
!!ARBfp1.0
# Custom YUV->RGB conversion program for MPlayer's -vo gl.
# Copyleft (C) Reimar Döffinger, 2005
# Licensed under the GNU GPL v2 or later
# Usage: mplayer -vo gl:yuv=4:customprog=emboss.fp
# This is an emboss effect.
PARAM sizes = program.env[0];
TEMP res, yuv, pos, tmp;
TEX yuv.r, fragment.texcoord[0], texture[0], 2D;
MAD pos, sizes.xyxy, {-0.5, 0, 0, -0.8660}, fragment.texcoord[0].xyxy;
TEX tmp.r, pos.xyxy, texture[0], 2D;
MAD yuv.r, yuv.rrrr, {2}, -tmp.rrrr;
TEX tmp.r, pos.zwzw, texture[0], 2D;
SUB yuv.r, yuv.rrrr, tmp.rrrr;
TEX yuv.g, fragment.texcoord[1], texture[1], 2D;
TEX yuv.b, fragment.texcoord[2], texture[2], 2D;
# now do the normal YUV -> RGB conversion but with 0.5 offset
MAD res, yuv.rrrr, {1.164, 1.164, 1.164, 0}, {-0.37416, 1.03133, -0.58599, 0.125};
MAD res.rgb, yuv.gggg, {0, -0.391, 2.018, 0}, res;
MAD res.rgb, yuv.bbbb, {1.596, -0.813, 0, 0}, res;
# do gamma texture lookup
TEX res.r, res.raaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.g, res.gaaa, texture[3], 2D;
ADD res.a, res.a, 0.25;
TEX res.b, res.baaa, texture[3], 2D;
# move res into result, this allows easily commenting out some parts.
MOV result.color, res;
END

View File

@ -1,241 +0,0 @@
/*
* benchmark tool for fast_memcpy code from libvo
*
* NOTE: This code can not be used on Pentium MMX / II because they contain
* a bug in rdtsc. For Intel processors since P6(PII) rdpmc should be used
* instead. For PIII it's disputable and it seems the bug was fixed but this
* was not confirmed through testing.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <inttypes.h>
#include "config.h"
#include "cpudetect.h"
#define BLOCK_SIZE 4096
#define CONFUSION_FACTOR 0
#if HAVE_MMX
#define COMPILE_MMX
#endif
#if HAVE_MMX2
#define COMPILE_MMX2
#endif
#if HAVE_AMD3DNOW
#define COMPILE_AMD3DNOW
#endif
#if HAVE_SSE
#define COMPILE_SSE
#endif
#ifdef COMPILE_MMX
#undef RENAME
#undef HAVE_MMX
#undef HAVE_MMX2
#undef HAVE_AMD3DNOW
#undef HAVE_SSE
#undef HAVE_SSE2
#define HAVE_MMX 1
#define HAVE_MMX2 0
#define HAVE_AMD3DNOW 0
#define HAVE_SSE 0
#define HAVE_SSE2 0
#define RENAME(a) a ## _MMX
#include "libvo/aclib_template.c"
#endif
#ifdef COMPILE_MMX2
#undef RENAME
#undef HAVE_MMX
#undef HAVE_MMX2
#undef HAVE_AMD3DNOW
#undef HAVE_SSE
#undef HAVE_SSE2
#define HAVE_MMX 1
#define HAVE_MMX2 1
#define HAVE_AMD3DNOW 0
#define HAVE_SSE 0
#define HAVE_SSE2 0
#define RENAME(a) a ## _MMX2
#include "libvo/aclib_template.c"
#endif
#ifdef COMPILE_AMD3DNOW
#undef RENAME
#undef HAVE_MMX
#undef HAVE_MMX2
#undef HAVE_AMD3DNOW
#undef HAVE_SSE
#undef HAVE_SSE2
#define HAVE_MMX 1
#define HAVE_MMX2 0
#define HAVE_AMD3DNOW 1
#define HAVE_SSE 0
#define HAVE_SSE2 0
#define RENAME(a) a ## _3DNow
#include "libvo/aclib_template.c"
#endif
#ifdef COMPILE_SSE
#undef RENAME
#undef HAVE_MMX
#undef HAVE_MMX2
#undef HAVE_AMD3DNOW
#undef HAVE_SSE
#undef HAVE_SSE2
#define HAVE_MMX 1
#define HAVE_MMX2 1
#define HAVE_AMD3DNOW 0
#define HAVE_SSE 1
#define HAVE_SSE2 1
#define RENAME(a) a ## _SSE
#include "libvo/aclib_template.c"
#endif
//#define ARR_SIZE 100000
#define ARR_SIZE (1024*768*2)
#ifdef CONFIG_MGA
#include "drivers/mga_vid.h"
static mga_vid_config_t mga_vid_config;
static unsigned char* frame = NULL;
static int f;
static int mga_init(void)
{
f = open("/dev/mga_vid", O_RDWR);
if (f == -1) {
fprintf(stderr, "Couldn't open /dev/mga_vid.\n");
return -1;
}
mga_vid_config.num_frames = 1;
mga_vid_config.frame_size = ARR_SIZE;
mga_vid_config.format = MGA_VID_FORMAT_YUY2;
mga_vid_config.colkey_on = 0;
mga_vid_config.src_width = 640;
mga_vid_config.src_height = 480;
mga_vid_config.dest_width = 320;
mga_vid_config.dest_height = 200;
mga_vid_config.x_org = 0;
mga_vid_config.y_org = 0;
mga_vid_config.version = MGA_VID_VERSION;
if (ioctl(f, MGA_VID_CONFIG, &mga_vid_config)) {
perror("Error in mga_vid_config ioctl()");
printf("Your mga_vid driver version is incompatible with this MPlayer version!\n");
exit(1);
}
ioctl(f, MGA_VID_ON, 0);
frame = (char*)mmap(0, mga_vid_config.frame_size*mga_vid_config.num_frames,
PROT_WRITE,MAP_SHARED, f, 0);
if (!frame) {
printf("Can't mmap MGA frame.\n");
exit(1);
}
//clear the buffer
//memset(frames[0], 0x80, mga_vid_config.frame_size*mga_vid_config.num_frames);
return 0;
}
#endif
// Returns current time in microseconds
static unsigned int GetTimer(void)
{
struct timeval tv;
struct timezone tz;
//float s;
gettimeofday(&tv, &tz);
//s = tv.tv_usec; s *= 0.000001; s += tv.tv_sec;
return tv.tv_sec * 1000000 + tv.tv_usec;
}
static inline unsigned long long int read_tsc(void)
{
unsigned long long int retval;
__asm__ volatile ("rdtsc":"=A" (retval)::"memory");
return retval;
}
unsigned char __attribute__((aligned(4096)))arr1[ARR_SIZE], arr2[ARR_SIZE];
int main(void)
{
unsigned long long int v1, v2;
unsigned char *marr1, *marr2;
int i;
unsigned int t;
#ifdef CONFIG_MGA
mga_init();
marr1 = &frame[3];
#else
marr1 = &arr1[0];
#endif
marr2 = &arr2[0];
for (i = 0; i < ARR_SIZE - 16; i++)
marr1[i] = marr2[i] = i;
#define testblock(func, name) \
t = GetTimer(); \
v1 = read_tsc(); \
for (i = 0; i < 100; i++) \
func(marr1, marr2, ARR_SIZE - 16); \
v2 = read_tsc(); \
t = GetTimer() - t; \
/* ARR_SIZE*100 / (1024*1024) / (t/1000000) = ARR_SIZE*95.36743 / t */ \
printf(name "CPU clocks=%llu = %dus (%5.3ffps) %5.1fMB/s\n", v2-v1, t, \
100000000.0f / (float)t, (float)ARR_SIZE*95.36743f / (float)t);
testblock(memcpy, "libc: ");
#if HAVE_MMX
testblock(fast_memcpy_MMX, "MMX: ");
#endif
#if HAVE_AMD3DNOW
testblock(fast_memcpy_3DNow, "3DNow!: ");
#endif
#if HAVE_MMX2
testblock(fast_memcpy_MMX2, "MMX2: ");
#endif
#if HAVE_SSE
testblock(fast_memcpy_SSE, "SSE: ");
#endif
return 0;
}

View File

@ -1,18 +0,0 @@
#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.
if [ -z "$1" ]; then
echo "Usage: midentify.sh <file> [<file> ...]"
exit 1
fi
mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
sed -ne '/^ID_/ {
s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
}'

View File

@ -1,182 +0,0 @@
/*
* A program to modify a registry file.
*
* Copyright (C) 2007 Alan Nisota
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <unistd.h>
#include <getopt.h>
#include "loader/registry.c"
#include "mp_msg.h"
#ifdef __GNUC__
#define mp_msg(t, l, m, args...) fprintf(stderr, m, ##args)
#else
#define mp_msg(t, l, ...) fprintf(stderr, __VA_ARGS__)
#endif
#include "get_path.c"
static void remove_key(long handle, const char* name) {
int i, len;
char *fullname;
fullname = build_keyname(handle, name);
len = strlen(fullname);
for (i=0; i < reg_size;) {
if (!strncmp(regs[i].name, fullname, len)) {
free(regs[i].value);
free(regs[i].name);
memmove(&regs[i], &regs[i+1], --reg_size*sizeof(struct reg_value));
} else {
i++;
}
}
free(fullname);
save_registry();
}
static void parse_key(char *raw, HKEY *root, char *path, char *key) {
char *tmpkey, *start;
tmpkey = strrchr(raw, '\\');
if (tmpkey == raw || tmpkey == NULL) {
printf("Couldn't process key \"%s\"\n", raw);
return;
}
start = strchr(raw, '\\');
if (start == raw || start == NULL) {
printf("Couldn't process key \"%s\"\n", raw);
return;
}
if (strncmp(raw, "HKEY_CURRENT_USER\\", 18) == 0 ||
strncmp(raw, "HKCU\\", 5) == 0) {
*root = HKEY_CURRENT_USER;
} else if (strncmp(raw, "HKEY_LOCAL_MACHINE\\", 19) == 0 ||
strncmp(raw, "HKLM\\", 5) == 0) {
*root = HKEY_LOCAL_MACHINE;
} else {
printf("Couldn't process key \"%s\"\n", raw);
return;
}
strncpy(key, tmpkey + 1, strlen(tmpkey)-1);
key[strlen(tmpkey)-1] = 0;
while(*start == '\\')
start++;
while(*(tmpkey-1) == '\\')
tmpkey--;
strncpy(path, start, tmpkey - start);
path[tmpkey - start] = 0;
}
int main(int argc, char *argv[]) {
int i;
long type = REG_SZ;
char c, path[256], key[256], *value = NULL;
HKEY root = 0;
int Option_Index;
int list = 0, del = 0;
int newkey, status;
static struct option Long_Options[] = {
{"registry", 1, 0, 'r'},
{"list", 0, 0, 'l'},
{"key", 1, 0, 'k'},
{"value", 1, 0, 'v'},
{"type", 1, 0, 't'},
{"del", 0, 0, 'd'},
};
while(1) {
c = getopt_long(argc, argv, "r:lk:v:t:id", Long_Options, &Option_Index);
if (c == EOF)
break;
switch(c) {
case 'r':
localregpathname = optarg;
break;
case 'l':
list = 1;
break;
case 'k':
parse_key(optarg, &root, path, key);
break;
case 'v':
value = optarg;
break;
case 't':
if (!strcmp(optarg, "string"))
type = REG_SZ;
else if (!strcmp(optarg, "dword"))
type = REG_DWORD;
break;
case 'd':
del = 1;
break;
}
}
if (localregpathname == NULL || (! list && ! root)) {
printf("Must specify '-r' and either '-k' or '-l'\n");
return 1;
}
if (del && (list || value)) {
printf("Can't specify '-d' along with '-l' or '-v'\n");
return 1;
}
open_registry();
insert_handle(HKEY_LOCAL_MACHINE, "HKLM");
insert_handle(HKEY_CURRENT_USER, "HKCU");
if (del) {
char tmpname[256];
sprintf(tmpname, "%s\\%s", path, key);
remove_key(root, tmpname);
return 0;
}
if (list) {
for (i=0; i < reg_size; i++) {
if (regs[i].type == DIR) {
printf("Directory: %s\n", regs[i].name);
} else if (regs[i].type == REG_DWORD) {
DWORD v = *(DWORD *)regs[i].value;
printf("%s :: %08x type: DWORD\n", regs[i].name, v);
} else if (regs[i].type == REG_SZ) {
printf("%s :: '%s' len: %d type: String\n",
regs[i].name, regs[i].value, regs[i].len);
} else {
printf("%s :: '%s' len: %d type: %08x\n",
regs[i].name, regs[i].value, regs[i].len, regs[i].type);
}
}
}
if (root) {
RegCreateKeyExA(root, path, 0, 0, 0, 0, 0, &newkey, &status);
if (value != NULL) {
int len;
DWORD v;
if (type == REG_DWORD) {
len = sizeof(DWORD);
v = strtoul(value, NULL, 0);
value = (char *)&v;
} else
len = strlen(value)+1;
printf("%08x -- %d\n", *value, len);
RegSetValueExA(newkey, key, 0, type, value, len);
}
}
return 0;
}

View File

@ -1,356 +0,0 @@
/* show QuickTime .mov file structure (C) 2001. by A'rpi/ESP-team
* various hacks by alex@naxine.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
Blocks: 4bytes atom_size
4bytes atom_type (name)
...
By older files, mdat is at the beginning, and moov follows it later,
by newer files, moov is at the begininng.
Fontosabb typeok:
trak: track: ezeken belul van egy-egy stream (video/audio)
tkhd: track header: fps (video esten picture size is itt van)
vmhd: video media handler (video stream informaciok)
smhd: sound media handler (audio stream informaciok)
*/
#include <stdio.h>
#include <stdlib.h>
#undef NO_SPECIAL
static char *atom2human_type(int type)
{
switch (type)
{
case 0x766F6F6D: return "Information sections"; /* moov */
case 0x6468766D: return "Movie header"; /* mvhd */
case 0x6169646D: return "Media stream"; /* mdia */
case 0x64686D76: return "Video media header"; /* vmhd */
case 0x64686D73: return "Sound media header"; /* smhd */
case 0x6468646D: return "Media header"; /* mdhd */
case 0x666E696D: return "Media information"; /* minf */
case 0x726C6468: return "Handler reference"; /* hdlr */
case 0x6B617274: return "New track (stream)"; /* trak */
case 0x75716D72: return "rmqu";
case 0x65657266: return "free";
case 0x64686B74: return "Track header"; /* tkhd */
case 0x61746475: return "User data"; /* udta */
case 0x7461646D: return "Movie data"; /* mdat */
case 0x6C627473: return "Sample information table"; /* stbl */
case 0x64737473: return "Sample description"; /* stsd */
case 0x6F637473: return "Chunk offset table"; /* stco */
case 0x73747473: return "Sample time table"; /* stts */
case 0x63737473: return "Sample->Chunk mapping table"; /* stsc */
case 0x7A737473: return "Sample size table"; /* stsz */
}
return "unknown";
}
#define S_NONE 0
#define S_AUDIO 1
#define S_VIDEO 2
int stream = S_NONE;
int v_stream = 0;
int a_stream = 0;
static unsigned int read_dword(FILE *f){
unsigned char atom_size_b[4];
if(fread(&atom_size_b,4,1,f)<=0) return -1;
return (atom_size_b[0]<<24)|(atom_size_b[1]<<16)|(atom_size_b[2]<<8)|atom_size_b[3];
}
static void video_stream_info(FILE *f, int len)
{
int orig_pos = ftell(f);
unsigned char data[len-8];
int i;
// char codec[len-8];
len -= 8;
for (i=0; i<len; i++)
fread(&data[i], 1, 1, f);
// strncpy(codec, &data[43], len-43);
// printf(" [codec: %s]\n", &codec);
fseek(f,orig_pos,SEEK_SET);
}
static void audio_stream_info(FILE *f, int len)
{
int orig_pos = ftell(f);
unsigned char data[len-8];
int i;
len -= 8;
for (i=0; i<len; i++)
fread(&data[i], 1, 1, f);
printf(" [%d bit", data[19]);
if (data[17] == 1)
printf(" mono");
else
printf(" %d channels", data[17]);
printf("]\n");
fseek(f,orig_pos,SEEK_SET);
}
#if 0
static void userdata_info(FILE *f, int len, int pos, int level)
{
int orig_pos = pos; /*ftell(f);*/
unsigned int atom_size = 1;
unsigned int atom_type;
// printf("userdata @ %d:%d (%d)\n", pos, pos+len, len);
// fseek(f, pos+3, SEEK_SET);
while (atom_size != 0)
{
atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break;
if(fread(&atom_type,4,1,f)<=0) break;
if(atom_size<8) break; // error
// printf("%08X: %*s %.4s (%08X) %05d (begin: %08X)\n",pos,level*2,"",
// &atom_type,atom_type,atom_size,pos+8);
switch(atom_type)
{
case 0x797063A9: /* cpy (copyright) */
{
char *data = malloc(atom_size-8);
fseek(f, pos+6, SEEK_SET);
fread(data, atom_size-8, 1, f);
printf(" Copyright: %s\n", data);
free(data);
}
break;
case 0x666E69A9: /* inf (information) */
{
char data[atom_size-8];
fread(&data, 1, atom_size-8, f);
printf(" Owner: %s\n", &data);
}
break;
case 0x6D616EA9: /* nam (name) */
{
char data[atom_size-8];
fread(&data, 1, atom_size-8, f);
printf(" Name: %s\n", &data);
}
break;
}
}
fseek(f,orig_pos,SEEK_SET);
}
#endif
int time_scale = 0;
static void lschunks(FILE *f,int level,unsigned int endpos){
unsigned int atom_size;
unsigned int atom_type;
int pos;
while(endpos==0 || ftell(f)<endpos){
pos=ftell(f);
atom_size=read_dword(f);// if(fread(&atom_size_b,4,1,f)<=0) break;
if(fread(&atom_type,4,1,f)<=0) break;
if(atom_size<8) break; // error
printf("%08X: %*s %.4s (%08X) %05d [%s] (begin: %08X)\n",pos,level*2,"",&atom_type,atom_type,atom_size,
atom2human_type(atom_type), pos+8); // 8: atom_size fields (4) + atom_type fields (4)
#ifndef NO_SPECIAL
// if (atom_type == 0x61746475)
// userdata_info(f, atom_size, pos, level);
if (atom_type == 0x6468646D)
{
char data[4];
fread(&data, 1, 1, f); // char
printf("mdhd version %d\n", data[0]);
fread(&data, 3, 1, f); // int24
fread(&data, 4, 1, f); // int32
fread(&data, 4, 1, f); // int32
fread(&data, 4, 1, f); // int32
time_scale = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
printf("timescale: %d\n", time_scale);
fread(&data, 4, 1, f); // int32
fread(&data, 2, 1, f); // int16
fread(&data, 2, 1, f); // int16
}
if (atom_type == 0x64686D76)
{
stream = S_VIDEO;
printf(" Found VIDEO Stream #%d\n", v_stream++);
}
if (atom_type == 0x64686D73)
{
stream = S_AUDIO;
printf(" Found AUDIO Stream #%d\n", a_stream++);
}
if (atom_type == 0x64686B74) // tkhd - track header
{
int i;
unsigned char data[atom_size];
int x, y;
for (i=0; i<atom_size; i++)
fread(&data[i], 1, 1, f);
x = data[77];
y = data[81];
printf(" Flags: %d\n", data[3]);
printf(" Picture size: %dx%d\n", x, y);
if (x == 0 && y == 0)
printf(" Possible audio stream!\n");
}
if(atom_type==0x64737473) { // stsd
unsigned int tmp;
unsigned int count;
int i;
fread(&tmp,4,1,f);
count=read_dword(f);// fread(&count,4,1,f);
printf("desc count = %d\n",count);
for(i=0;i<count;i++){
unsigned int len;
unsigned int format;
len=read_dword(f); // fread(&len,4,1,f);
fread(&format,4,1,f);
printf(" desc #%d: %.4s (%d)\n",i+1,&format,len);
if (stream == S_VIDEO)
video_stream_info(f, len);
if (stream == S_AUDIO)
audio_stream_info(f, len);
fseek(f,len-8,SEEK_CUR);
}
}
if(atom_type==0x6F637473) { // stco
int len,i;
read_dword(f);
len=read_dword(f);
printf("Chunk table size :%d\n",len);
for(i=0;i<len;i++) printf(" chunk #%d: 0x%X\n",i+1,read_dword(f));
}
if(atom_type==0x73747473) { // stts
int len,i;
read_dword(f);
len=read_dword(f);
printf("T->S table size :%d\n",len);
for(i=0;i<len;i++){
int num=read_dword(f);
int dur=read_dword(f);
printf("%5d samples: %d duration", num, dur);
if (stream == S_AUDIO)
printf("(rate: %f Hz)\n", (float)time_scale/dur);
else
printf("(fps: %f)\n", (float)time_scale/dur);
}
}
if(atom_type==0x63737473) { // stsc
int len,i;
read_dword(f);
len=read_dword(f);
printf("S->C table size :%d\n",len);
for(i=0;i<len;i++){
int first=read_dword(f);
int spc=read_dword(f);
int sdid=read_dword(f);
printf(" chunk %d... %d s/c desc: %d\n",first,spc,sdid);
}
}
if(atom_type==0x7A737473) { // stsz
int len,i,ss;
read_dword(f);
ss=read_dword(f);
len=read_dword(f);
printf("Sample size table len: %d\n",len);
if(ss){
printf(" common sample size: %d bytes\n",ss);
} else {
for(i=0;i<len;i++) printf(" sample #%d: %d bytes\n",i+1,read_dword(f));
}
}
#endif
#if 1
switch(atom_type){
case 0x7461646D: // mdat Movie data
case 0x75716D72: // rmqu
case 0x65657266: // free JUNK
case 0x64686B74: // tkhd Track header
case 0x61746475: // udta User data
case 0x64737473: // stsd Sample description
case 0x6F637473: // stco Chunk offset table
case 0x73747473: // stts Sample time table
case 0x63737473: // stsc Sample->Chunk mapping table
case 0x7A737473: // stsz Sample size table
case 0x746f6e70: // pnot
case 0x54434950: // PICT
case 0x70797466:
break;
default: lschunks(f,level+1,pos+atom_size);
}
#else
switch(atom_type){
case 0x766F6F6D: // moov
case 0x61726D72: // rmra
case 0x61646D72: // rmda
lschunks(f,level+1,pos+atom_size);
}
#endif
fseek(f,pos+atom_size,SEEK_SET);
}
}
int main(int argc,char* argv[])
{
FILE *f;
if ((f = fopen(argc>1?argv[1]:"Akira.mov","rb")) == NULL)
return 1;
printf("%.8s %.4s (%.8s) %5s [%s]\n\n",
"position", "atom", "atomtype", "len", "human readable atom name");
lschunks(f, 0, 0);
printf("\nSummary: streams: %d video/%d audio\n", v_stream, a_stream);
return 0;
}

View File

@ -1,12 +0,0 @@
#!/bin/sh
# Script to run mplayer on the console (fbdev/mga_vid/etc) without
# the console text and/or flashing cursor getting in the way.
# Written by Rich Felker.
trap "tput cnorm ; exit 1" SIGQUIT SIGINT EXIT
res=`PATH="$PATH:/usr/sbin" fbset | grep geometry | sed 's/^ *//'`
width=`echo "$res" | cut -d' ' -f2`
height=`echo "$res" | cut -d' ' -f3`
tput civis
clear
mplayer -vo mga -screenw "$width" -screenh "$height" "$@" >/dev/null 2>&1

View File

@ -1,66 +0,0 @@
#!/usr/bin/python
# Tool to compare MPlayer translation files against a base file. Reports
# conflicting arguments, extra strings not present in the base file and
# (optionally) missing strings.
# Written by Uoti Urpala
import sys
import re
def parse(filename):
r = {}
f = open(filename)
it = iter(f)
cur = ''
for line in it:
line = line.strip()
if not line.startswith('#define'):
while line and line[-1] == '\\':
line = it.next().strip()
continue
_, name, value = line.split(None, 2)
value = value.strip('"')
while line[-1] == '\\':
line = it.next().strip()
value += line.rstrip('\\').strip('"')
r[name] = value
f.close()
return r
def compare(base, other, show_missing=False):
r = re.compile('%[^diouxXeEfFgGaAcspn%]*[diouxXeEfFgGaAcspn%]')
missing = []
for key in base:
if key not in other:
missing.append(key)
continue
if re.findall(r, base[key]) != re.findall(r, other[key]):
print 'Mismatch: ', key
print base[key]
print other[key]
print
del other[key]
if other:
extra = other.keys()
extra.sort()
print 'Extra: ', ' '.join(extra)
if show_missing and missing:
missing.sort()
print 'Missing: ', ' '.join(missing)
if len(sys.argv) < 3:
print 'Usage:\n'+sys.argv[0]+' [--missing] base_helpfile otherfile1 '\
'[otherfile2 ...]'
sys.exit(1)
i = 1
show_missing = False
if sys.argv[i] in ( '--missing', '-missing' ):
show_missing = True
i = 2
base = parse(sys.argv[i])
for filename in sys.argv[i+1:]:
print '*****', filename
compare(base, parse(filename), show_missing)
print '\n'

View File

@ -1,45 +0,0 @@
#!/bin/sh
# example how to output video on multiple windows in sync.
# might be even more useful in combination with vo ggi
# to distribute the video arbitrarily
dir=/tmp/$$
count=$1
shift
if test 0"$count" -lt 1; then
echo "At least 1 slave instance must be used."
echo ""
echo "Usage:"
echo "./mplmult.sh n mplayer-opts"
echo "n number of MPlayer instances that display the video"
echo "mplayer-opts anything you would specify to mplayer,"
echo " more than one file will usually not work"
exit 1
fi
mkdir -m 700 $dir
if test $? -ne 0; then
echo "Could not create temp dir!"
exit 1
fi
mkfifo $dir/stream.yuv
i=1
fifo_list=""
while test $i -le $count; do
fifo_list="$dir/mp$i $fifo_list"
i=$(($i+1))
done
mkfifo $fifo_list
(cat $dir/stream.yuv | tee $fifo_list > /dev/null ) &
for fifo in $fifo_list; do
# -benchmark is neccessary so that it will not do any timing.
# the master instance already takes care of it and not specifying
# it will break A-V sync.
mplayer -nocache -quiet -benchmark "$fifo" > /dev/null 2>&1 &
done
mplayer -nocache -fixed-vo -vo yuv4mpeg:file=$dir/stream.yuv "$@"
rm -rf $dir

View File

@ -1,366 +0,0 @@
/*
* Copyright (C) Alban Bedel - 04/2003
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <errno.h>
#include <signal.h>
#include <sys/types.h>
#include "config.h"
#if !HAVE_WINSOCK2_H
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#include "stream/stream.h"
#include "libmpdemux/demuxer.h"
#include "mp_msg.h"
#include "libavutil/common.h"
#include "mpbswap.h"
/// Netstream packets def and some helpers
#include "stream/stream_netstream.h"
// linking hacks
char *info_name;
char *info_artist;
char *info_genre;
char *info_subject;
char *info_copyright;
char *info_sourceform;
char *info_comment;
char* out_filename = NULL;
char* force_fourcc=NULL;
char* passtmpfile="divx2pass.log";
static unsigned short int port = 10000;
typedef struct client_st client_t;
struct client_st {
int fd;
stream_t* stream;
client_t* next;
client_t* prev;
};
static int write_error(int fd,char* msg) {
int len = strlen(msg) + 1;
return write_packet(fd,NET_STREAM_ERROR,msg,len);
}
static int net_stream_open(client_t* cl,char* url) {
int file_format=DEMUXER_TYPE_UNKNOWN;
mp_net_stream_opened_t ret;
if(cl->stream) {
if(!write_error(cl->fd,"A stream is currently opened\n"))
return 0;
return 1;
}
mp_msg(MSGT_NETST,MSGL_V,"Open stream %s\n",url);
cl->stream = open_stream(url,NULL,&file_format);
if(!cl->stream) {
if(!write_error(cl->fd,"Open failed\n"))
return 0;
return 1;
}
stream_reset(cl->stream);
stream_seek(cl->stream,cl->stream->start_pos);
ret.file_format = file_format;
ret.flags = cl->stream->flags;
ret.sector_size = cl->stream->sector_size;
ret.start_pos = cl->stream->start_pos;
ret.end_pos = cl->stream->end_pos;
net_stream_opened_2_me(&ret);
if(!write_packet(cl->fd,NET_STREAM_OK,(char*)&ret,sizeof(mp_net_stream_opened_t)))
return 0;
return 1;
}
static int net_stream_fill_buffer(client_t* cl,uint16_t max_len) {
int r;
mp_net_stream_packet_t *pack;
if(!cl->stream) {
if(!write_error(cl->fd,"No stream is currently opened\n"))
return 0;
return 1;
}
if(max_len == 0) {
if(!write_error(cl->fd,"Fill buffer called with 0 length\n"))
return 0;
return 1;
}
pack = malloc(max_len + sizeof(mp_net_stream_packet_t));
pack->cmd = NET_STREAM_OK;
r = stream_read(cl->stream,pack->data,max_len);
pack->len = le2me_16(r + sizeof(mp_net_stream_packet_t));
if(!net_write(cl->fd,(char*)pack,le2me_16(pack->len))) {
free(pack);
return 0;
}
free(pack);
return 1;
}
static int net_stream_seek(client_t* cl, uint64_t pos) {
if(!cl->stream) {
if(!write_error(cl->fd,"No stream is currently opened\n"))
return 0;
return 1;
}
if(!stream_seek(cl->stream,(off_t)pos)) {
if(!write_error(cl->fd,"Seek failed\n"))
return 0;
return 1;
}
if(!write_packet(cl->fd,NET_STREAM_OK,NULL,0))
return 0;
return 1;
}
static int net_stream_reset(client_t* cl) {
if(!cl->stream) {
if(!write_error(cl->fd,"No stream is currently opened\n"))
return 0;
return 1;
}
stream_reset(cl->stream);
if(!write_packet(cl->fd,NET_STREAM_OK,NULL,0))
return 0;
return 1;
}
static int net_stream_close(client_t* cl) {
if(!cl->stream) {
if(!write_error(cl->fd,"No stream is currently opened\n"))
return 0;
return 1;
}
free_stream(cl->stream);
cl->stream = NULL;
if(!write_packet(cl->fd,NET_STREAM_OK,NULL,0))
return 0;
return 1;
}
static int handle_client(client_t* cl,mp_net_stream_packet_t* pack) {
if(!pack)
return 0;
switch(pack->cmd) {
case NET_STREAM_OPEN:
if(((char*)pack)[pack->len-1] != '\0') {
mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid open packet\n");
return 0;
}
return net_stream_open(cl,pack->data);
case NET_STREAM_FILL_BUFFER:
if(pack->len != sizeof(mp_net_stream_packet_t) + 2) {
mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid fill buffer packet\n");
return 0;
}
return net_stream_fill_buffer(cl,le2me_16(*((uint16_t*)pack->data)));
case NET_STREAM_SEEK:
if(pack->len != sizeof(mp_net_stream_packet_t) + 8) {
mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid fill buffer packet\n");
return 0;
}
return net_stream_seek(cl,le2me_64(*((uint64_t*)pack->data)));
case NET_STREAM_RESET:
return net_stream_reset(cl);
case NET_STREAM_CLOSE:
if(pack->len != sizeof(mp_net_stream_packet_t)){
mp_msg(MSGT_NETST,MSGL_WARN,"Got invalid fill buffer packet\n");
return 0;
}
return net_stream_close(cl);
default:
mp_msg(MSGT_NETST,MSGL_WARN,"Got unknown command %d\n",pack->cmd);
if(!write_error(cl->fd,"Unknown command\n"))
return 0;
}
return 0;
}
static client_t* add_client(client_t *head,int fd) {
client_t *new = calloc(1,sizeof(client_t));
new->fd = fd;
if(!head) return new;
new->next = head;
head->prev = new;
return new;
}
static int make_fd_set(fd_set* fds, client_t** _cl, int listen) {
int max_fd = listen;
client_t *cl = *_cl;
FD_ZERO(fds);
FD_SET(listen,fds);
while(cl) {
// Remove this client
if(cl->fd < 0) {
client_t* f = cl;
if(cl->prev) cl->prev->next = cl->next;
if(cl->next) cl->next->prev = cl->prev;
if(cl->stream) free_stream(cl->stream);
if(!cl->prev) // Remove the head
*_cl = cl->next;
cl = cl->next;
free(f);
continue;
}
FD_SET(cl->fd,fds);
if(cl->fd > max_fd) max_fd = cl->fd;
cl = cl->next;
}
return max_fd+1;
}
/// Hack to 'cleanly' exit
static int run_server = 1;
void exit_sig(int sig) {
static int count = 0;
sig++; // gcc warning
count++;
if(count==3) exit(1);
if(count > 3)
#ifdef __MINGW32__
WSACleanup();
#else
kill(getpid(),SIGKILL);
#endif
run_server = 0;
}
static int main_loop(int listen_fd) {
client_t *clients = NULL,*iter;
fd_set fds;
signal(SIGTERM,exit_sig); // kill
#ifndef __MINGW32__
signal(SIGHUP,exit_sig); // kill -HUP / xterm closed
signal(SIGINT,exit_sig); // Interrupt from keyboard
signal(SIGQUIT,exit_sig); // Quit from keyboard
#endif
while(run_server) {
int sel_n = make_fd_set(&fds,&clients,listen_fd);
int n = select(sel_n,&fds,NULL,NULL,NULL);
if(n < 0) {
if(errno == EINTR)
continue;
mp_msg(MSGT_NETST,MSGL_FATAL,"Select error: %s\n",strerror(errno));
return 1;
}
// New connection
if(FD_ISSET(listen_fd,&fds)) {
struct sockaddr_in addr;
socklen_t slen = sizeof(struct sockaddr_in);
int client_fd = accept(listen_fd,(struct sockaddr*)&addr,&slen);
if(client_fd < 0) {
mp_msg(MSGT_NETST,MSGL_ERR,"accept failed: %s\n",strerror(errno));
continue;
}
mp_msg(MSGT_NETST,MSGL_V,"New client from %s\n",inet_ntoa(addr.sin_addr));
clients = add_client(clients,client_fd);
if(n == 1) continue;
}
// Look for the clients
for(iter = clients ; iter ; iter = iter->next) {
mp_net_stream_packet_t* pack;
if(!FD_ISSET(iter->fd,&fds)) continue;
pack = read_packet(iter->fd);
if(!pack) {
close(iter->fd);
iter->fd = -1;
continue;
}
if(!handle_client(iter,pack)) {
close(iter->fd);
iter->fd = -1;
}
free(pack);
}
}
mp_msg(MSGT_NETST,MSGL_INFO,"Exit ....\n");
close(listen_fd);
#ifdef __MINGW32__
WSACleanup();
#endif
while(clients) {
client_t* f = clients;
if(f->stream) free_stream(f->stream);
if(f->fd > 0) close(f->fd);
free(f);
clients = clients->next;
}
return 0;
}
int main(void) {
int listen_fd;
struct sockaddr_in addr;
mp_msg_init();
// mp_msg_set_level(verbose+MSGL_STATUS);
#ifdef __MINGW32__
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1), &wsaData);
#endif
listen_fd = socket(AF_INET, SOCK_STREAM, 0);
if(listen_fd < 0) {
mp_msg(MSGT_NETST,MSGL_FATAL,"Failed to create listen_fd: %s\n",strerror(errno));
return -1;
}
memset(&addr,0,sizeof(struct sockaddr));
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
addr.sin_family = AF_INET;
if(bind(listen_fd,(struct sockaddr*)&addr,sizeof(struct sockaddr))) {
mp_msg(MSGT_NETST,MSGL_FATAL,"Failed to bind listen socket: %s\n",strerror(errno));
return -1;
}
if(listen(listen_fd,1)) {
mp_msg(MSGT_NETST,MSGL_FATAL,"Failed to turn the socket in listen state: %s\n",strerror(errno));
return -1;
}
return main_loop(listen_fd);
}

View File

@ -1,234 +0,0 @@
#!/usr/bin/perl
#
# Licence: GPL
#
# 2003/02/09 Jonas Jermann <jjermann@gmx.net>
#
# Script: Draw PSNR log graphs using gnuplot
#
# requires: gnuplot
use Getopt::Long;
# MAIN
my %options;
my $dem_file="psnr.dem";
commandline();
demo_file();
system ("gnuplot $dem_file");
system("rm $dem_file $options{file}.[IPB] $options{file}.diff* 2>/dev/null");
exit 0;
# DEMO FILE
sub demo_file {
if ($options{file2}) {
my @file1_cont = ();
my @file2_cont = ();
my $NewRow,$i,$j;
open(LIST_IN, "$options{file}"); while( <LIST_IN> ) {
$NewRow=[];
@$NewRow = split(/[ ,]+/, $_);
push( @file1_cont, $NewRow );
}
close(LIST_IN);
open(LIST_IN2, "$options{file2}"); while( <LIST_IN2> ) {
$NewRow=[];
@$NewRow = split(/[ ,]+/, $_);
push( @file2_cont, $NewRow );
}
close(LIST_IN2);
open(LIST_OUT, ">$options{file}.diff");
for($i=0; $i<=$#file2_cont; $i++) {
print LIST_OUT " $file2_cont[$i]->[1],\ ";
for($j=2; $j<=7; $j++) {
$file2_cont[$i]->[$j] -= $file1_cont[$i]->[$j];
print LIST_OUT " $file2_cont[$i]->[$j],\ ";
}
print LIST_OUT " $file2_cont[$i]->[8]\n";
}
close(LIST_OUT);
$options{file}="$options{file}.diff";
}
if ($options{iframes}) { system("cat $options{file} | grep I > $options{file}.I"); }
if ($options{pframes}) { system("cat $options{file} | grep P > $options{file}.P"); }
if ($options{bframes}) { system("cat $options{file} | grep B > $options{file}.B"); }
open(DEM_FILE,">$dem_file");
print DEM_FILE "#PSNR Statistics
#---------------
set title \"PSNR Statistics\"
set data style fsteps
set xlabel \"Frames\"
set grid
";
if ($options{quant}) {
print DEM_FILE "# Quantizers
plot [] [0:] \\";
if ($options{pframes}) {
print DEM_FILE "
\"$options{file}.P\" using 1:2 t \"Quantizer: P frames\" w $options{qs}";
if ($options{bframes} || $options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{bframes}) {
print DEM_FILE "
\"$options{file}.B\" using 1:2 t \"Quantizer: B frames\" w $options{qs}";
if ($options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{iframes}) {
print DEM_FILE "
\"$options{file}.I\" using 1:2 t \"Quantizer: I frames\" w $options{qs}";
}
if (!($options{pframes} || $options{bframes} || $options{iframes})) {
print DEM_FILE "
\"$options{file}\" using 1:2 t \"Quantizer\" w $options{qs}";
}
print DEM_FILE "
pause -1
";
}
if ($options{size}) {
print DEM_FILE "# Frame size
plot \\";
if ($options{pframes}) {
print DEM_FILE "
\"$options{file}.P\" using 1:3 t \"Size: P frames\" w $options{ss}";
if ($options{bframes}||$options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{bframes}) {
print DEM_FILE "
\"$options{file}.B\" using 1:3 t \"Size: B frames\" w $options{ss}";
if ($options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{iframes}) {
print DEM_FILE "
\"$options{file}.I\" using 1:3 t \"Size: I frames\" w $options{ss}";
}
if (!($options{pframes}||$options{bframes}||$options{iframes})) {
print DEM_FILE "
\"$options{file}\" using 1:3 t \"Size\" w $options{ss}";
}
print DEM_FILE "
pause -1
";
}
if ($options{psnr}) {
print DEM_FILE "# PSNR
plot \\";
if ($options{pframes}) {
print DEM_FILE "
\"$options{file}.P\" using (\$1):(\$7) t \"PSNR (All): P frames\" w $options{ps}";
if ($options{bframes}||$options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{bframes}) {
print DEM_FILE "
\"$options{file}.B\" using (\$1):(\$7) t \"PSNR (All): B frames\" w $options{ps}";
if ($options{iframes}) { print DEM_FILE ",\\"; }
}
if ($options{iframes}) {
print DEM_FILE "
\"$options{file}.I\" using (\$1):(\$7) t \"PSNR (All): I frames\" w $options{ps}";
}
if (!($options{pframes}||$options{bframes}||$options{iframes})) {
print DEM_FILE "
\"$options{file}\" using (\$1):(\$7) t \"PSNR (All)\" w $options{ps}";
}
print DEM_FILE "
#\"$options{file}\" using (\$1):(\$4) t \"PSNR (Y)\" w $options{ps} \\
#\"$options{file}\" using (\$1):(\$5) t \"PSNR (Cb)\" w $options{ps} \\
#\"$options{file}\" using (\$1):(\$6) t \"PSNR (Cr)\" w $options{ps}
pause -1
";
}
print DEM_FILE "
reset";
close (DEM_FILE);
}
# USAGE
sub usage {
print STDERR <<EOF;
Usage: plotpsnr.pl [options] 'file'
Options:
-h, --help Display this help message
-quant Display quantizers
-size Display size
-psnr Display PSNR
-iframes Display I frames
-pframes Display P frames
-bframes Display B frames
-aframes Display all frames in different colors
-cmp <file2> Compare two files
-qs <style> Quantizer style
-ss <style> Size style
-ps <style> PSNR style
Default: -quant -size -psnr -qs "p" -ss "i" -ps "p"
Notes:
Comparison is based on file2.
Comparison assumes that the frame numbers of both files fit.
EOF
exit 1;
}
# COMMAND LINE
sub commandline {
$options{qs}="p";
$options{ss}="i";
$options{ps}="p";
GetOptions(
"help|h" => \&usage,
"quant" => \$options{quant},
"size" => \$options{size},
"psnr" => \$options{psnr},
"cmp=s" => \$options{file2},
"iframes" => \$options{iframes},
"pframes" => \$options{pframes},
"bframes" => \$options{bframes},
"aframes" => sub { $options{iframes} = 1;
$options{pframes} = 1;
$options{bframes} = 1; },
"qs=s" => \$options{qs},
"ss=s" => \$options{ss},
"ps=s" => \$options{ps},
) || usage();
if (!($options{quant}||$options{size}||$options{psnr})) {
$options{quant}=1;
$options{size}=1;
$options{psnr}=1;
}
$options{file}="@ARGV";
}

View File

@ -1,179 +0,0 @@
#!/bin/bash
# Helper script to ease comparing the PSNR between two video files
# Copyleft 2005 by Matthias Wieser
# Copyleft 2005 by Ivo
# This file comes under GPL, see http://www.gnu.org/copyleft/gpl.html for more
# information on its licensing.
warning_frame_number () {
echo "Files have differing numbers of frames!"
echo "$FILE1 has `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` frames,"
echo "$FILE2 has `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
echo "Processing the first `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` frames."
}
TEMPDIR="/tmp/psnr_video"
WORKDIR=`pwd`
OUTFILE=psnr.dat
ERRFILE=errorsum.del
exit=0
if [[ `which pnmpsnr 2> /dev/null` = "" ]]
then
echo
echo "To use this script you have to install the program \"pnmpsnr\" which is"
echo " included in the netpbm package."
echo
exit=1
fi
if [[ `which bc 2> /dev/null` = "" ]]
then
echo
echo "To use this script you have to install the GNU command line calculator \"bc\"."
echo
exit=1
fi
if [ $# -le 1 ]; then
echo
echo "Usage: `basename $0` <file1> <file2> [<frames>] [<options1>] [<options2>]"
echo
echo " <file1> and <file2> are the files for which the PSNR should be calculated."
echo " [<frames>] is the number of frames to process, starting from frame 1."
echo " [<options1>] are additional MPlayer options for <file1>."
echo " [<options2>] are additional MPlayer options for <file2>."
echo
echo " Be aware that `basename $0` needs a lot of temporary space inside /tmp/."
echo
echo "Example:"
echo " ./`basename $0` ./orig.avi ./test.avi 250 \"\" \"-vf pp=ac\""
echo
exit=1
fi
if [ "$exit" -eq 1 ]; then
exit 1
fi
FILE1=$1
FILE2=$2
LastFrame=-1
if [ $# -ge 3 ]; then
LastFrame=$3
echo
echo "Will process $LastFrame frames."
fi
if [ $# -ge 4 ]; then
FILE1_Options=$4
echo "MPlayer options for ${FILE1}: $FILE1_Options"
fi
if [ $# -ge 5 ]; then
FILE2_Options=$5
echo "MPlayer options for ${FILE2}: $FILE2_Options"
fi
mkdir -p ${TEMPDIR}/FILE1
mkdir -p ${TEMPDIR}/FILE2
### File 1
echo
echo "############## $FILE1 #################"
cd ${TEMPDIR}/FILE1
rm -f *ppm
rm -f *del
if [ $LastFrame -ge 0 ]; then
mplayer $FILE1_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}/$FILE1 > /dev/null
else
mplayer $FILE1_Options -nosound -vo pnm ${WORKDIR}/$FILE1 > /dev/null
fi
### File 2
echo
echo "############## $FILE2 #################"
cd ${TEMPDIR}/FILE2
rm -f *ppm
if [ $LastFrame -ge 0 ]; then
mplayer $FILE2_Options -frames $LastFrame -nosound -vo pnm ${WORKDIR}/$FILE2 > /dev/null
else
mplayer $FILE2_Options -nosound -vo pnm ${WORKDIR}/$FILE2 > /dev/null
fi
### PSNR
echo
echo "############## PSNR Calculation #################"
if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
then
echo
else
warning_frame_number
echo
fi
cd ${TEMPDIR}/FILE2
#rm ../$OUTFILE
echo "File;Y;Cb;Cr" > ../$OUTFILE
echo "0" > $ERRFILE
i=0
for FILE in `ls -1 *.ppm`
do
echo $FILE
echo -n "$FILE" >> ../$OUTFILE
echo -n ";" >> ../$OUTFILE
YCBCR=`pnmpsnr ../FILE1/$FILE $FILE 2>&1 | tail -n 3 | cut -f 3 -d ':' | \
( read Y X; read CB X; read CR X; echo "$Y;$CB;$CR;")`
Y=`echo $YCBCR | cut -f 1 -d ';'`
CB=`echo $YCBCR | cut -f 2 -d ';'`
CR=`echo $YCBCR | cut -f 3 -d ';'`
echo $YCBCR >> ../$OUTFILE
ALL=`echo "(-10)*l((e(-$Y/10*l(10))+e(-$CB/10*l(10))/4+e(-$CR/10*l(10))/4)/1.5)/l(10)" | bc -l`
echo "$ALL" >> ../$OUTFILE
ERROR=`echo "scale=30; (e(-1*$Y/10*l(10))+e(-1*$CB/10*l(10))/4+e(-1*$CR/10*l(10))/4)/1.5" | bc -l`
ERRORSUM=`cat $ERRFILE`
echo `echo "scale=30; $ERROR + $ERRORSUM" | bc -l` > $ERRFILE
i=$(($i+1))
if [[ $i = $LastFrame ]]
then
break
fi
done
ERRORSUM=`cat $ERRFILE`
PSNR=`echo "-10*l($ERRORSUM/$i)/l(10)" | bc -l`
echo "PSNR:;$PSNR" >> ../$OUTFILE
cd ..
mv $OUTFILE ${WORKDIR}/
if [[ `ls -1 ${TEMPDIR}/FILE1/*ppm | wc -l` = `ls -1 ${TEMPDIR}/FILE2/*ppm | wc -l` ]]
then
echo
else
warning_frame_number
echo
fi
cd ..
rm -r ${TEMPDIR}
echo "Created ${WORKDIR}/$OUTFILE"
echo

View File

@ -1,445 +0,0 @@
#!/usr/bin/perl -w
# A script for pipelined editing of subtitle files.
# Copyright (C) 2004 Michael Klepikov <mike72@mail.ru>
#
# Version 1.0 initial release 28-Mar-04
#
# Comments, suggestions -- send me an mail, but the recommended way is
# to enhance/fix on your own and submit to the distribution;)
# If you like, I can review the fixes.
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# Retain original credits when modifying.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
use Math::BigInt;
# Constants
my $FMT_UNKNOWN = 0;
my $FMT_SRT = 1;
# Argument values
my $DEBUG = 0;
my $inFormat;
my $outFormat;
my $shiftMilli;
my $scaleMilli;
my $splitFromMilli;
my $splitToMilli;
## Process command line
while (defined ($argVal = shift)) {
if ($argVal eq "-d" || $argVal eq "--debug") {
$DEBUG = 1;
} elsif ($argVal eq "-if" || $argVal eq "--input-format") {
$inFormat = shift;
usage ("Must specify input format") if ! $inFormat;
if ($inFormat =~ /^srt/i) {
$inFormat = $FMT_SRT;
} else {
usage ("Invalid input format");
}
} elsif ($argVal eq "-of" || $argVal eq "--output-format") {
$outFormat = shift;
usage ("Must specify input format") if ! $outFormat;
if ($outFormat =~ /^srt/i) {
$outFormat = $FMT_SRT;
} else {
usage ("Invalid output format");
}
} elsif ($argVal eq "-s" || $argVal eq "--shift") {
my $argTime = shift;
if (! defined $argTime ||
! defined ($shiftMilli = getTimeMillis ($argTime))) {
usage ("Invalid shift time value");
}
} elsif ($argVal eq "-c" || $argVal eq "--scale") {
my $argTime = shift;
if (! defined $argTime ||
! defined ($scaleMilli = getTimeMillis ($argTime))) {
usage ("Invalid scale time value");
}
} elsif ($argVal eq "-f" || $argVal eq "--split-from") {
my $argTime = shift;
if (! defined $argTime ||
! defined ($splitFromMilli = getTimeMillis ($argTime))) {
usage ("Invalid split start time value");
}
} elsif ($argVal eq "-t" || $argVal eq "--split-to") {
my $argTime = shift;
if (! defined $argTime ||
! defined ($splitToMilli = getTimeMillis ($argTime))) {
usage ("Invalid split end time value");
}
} elsif ($argVal eq "-h" || $argVal eq "--help") {
usage ();
} else {
usage ("Unrecognized argument $argVal");
}
}
# Input format defaults to SRT
$inFormat = $FMT_SRT if (! defined $inFormat);
# Output format defaults to the same as input
$outFormat = $inFormat if (! defined $outFormat);
## Read
my $subs;
if ($inFormat == $FMT_SRT) {
$subs = readSRT (*STDIN);
printf STDERR ("Read %d SRT subs\n", scalar @{$subs}) if $DEBUG;
# Sort by start time
@{$subs} = sort {$a -> {srtStartTime} <=> $b -> {srtEndTime}} @{$subs};
}
## Transform
if (defined $shiftMilli && 0 != $shiftMilli) {
printf STDERR ("Shift: %d milliseconds\n", $shiftMilli) if $DEBUG;
shiftSRT ($subs, $shiftMilli);
}
if (defined $splitFromMilli || defined $splitToMilli) {
if ($DEBUG) {
my $printFrom = (defined $splitFromMilli) ? $splitFromMilli : "-";
my $printTo = (defined $splitToMilli) ? $splitToMilli : "-";
printf STDERR ("Split: from $printFrom to $printTo\n");
}
splitSRT ($subs, $splitFromMilli, $splitToMilli);
}
if (defined $scaleMilli && 0 != $scaleMilli) {
my $lastSubIdx = scalar @{$subs} - 1;
if ($lastSubIdx >= 0) {
my $lastTimeOrig = $subs -> [$lastSubIdx] -> {srtEndTime};
if ($lastTimeOrig == 0) {
die "Cannot scale when last subtitle ends at 00:00:00,000";
}
my $lastTimeScaled = $lastTimeOrig + $scaleMilli;
printf STDERR ("Scale: %d/%d\n", $lastTimeScaled, $lastTimeOrig) if $DEBUG;
scaleSRT ($subs, $lastTimeScaled, $lastTimeOrig);
}
}
## Write
if ($outFormat == $FMT_SRT) {
writeSRT (*STDOUT, $subs);
}
# Close STDOUT, as recommended by Perl manual
# (allows diagnostics on disc overflow, etc.)
close (STDOUT) || die "Cannot close output stream: $!";
exit 0;
## Subroutines
# Convert string time format to milliseconds
# SRT style: "01:20:03.251", and "," is allowed instead of "."
# Return undef in case of format error
sub getTimeMillis
{
$_ = shift;
my $millis = 0;
if (/\s*(.*)[\.,]([0-9]+)?\s*$/) { # Fraction; strip surrounding spaces
#print STDERR "frac: \$1=$1 \$2=$2\n" if $DEBUG;
$_ = $1;
$millis += ("0." . $2) * 1000 if $2;
}
if (/(.*?)([0-9]+)$/) { # Seconds
#print STDERR "secs: \$1=$1 \$2=$2\n" if $DEBUG;
$_ = $1;
$millis += $2 * 1000 if $2;
}
if (/(.*?)([0-9]+):$/) { # Minutes
#print STDERR "mins: \$1=$1 \$2=$2\n" if $DEBUG;
$_ = $1;
$millis += $2 * 60000 if $2;
}
if (/(.*?)([0-9]+):$/) { # Hours
#print STDERR "mins: \$1=$1 \$2=$2\n" if $DEBUG;
$_ = $1;
$millis += $2 * 3600000 if $2;
}
if (/(.*?)\-$/) { # Minus sign
$_ = $1;
$millis *= -1;
}
$millis = undef if (! /^$/); # Make sure we ate everything up
if ($DEBUG) {
if (defined $millis) {
#print STDERR "time value match: $millis ms\n";
} else {
#print STDERR "time mismatch\n";
}
}
return $millis;
}
# Convert milliseconds to SRT formatted string
sub getTimeSRT
{
my $t = shift;
my $tMinus = "";
if ($t < 0) {
$t = -$t;
$tMinus = "-";
}
my $tMilli = $t % 1000;
$t /= 1000;
my $tSec = $t % 60;
$t /= 60;
my $tMin = $t % 60;
$t /= 60;
my $tHr = $t;
return sprintf ("%s%02d:%02d:%02d,%03d",
$tMinus, $tHr, $tMin, $tSec, $tMilli);
}
# Read SRT subtitles
sub readSRT
{
local *IN = shift;
my $subs = [];
$_ = <IN>;
print STDERR "Undefined first line\n" if ! defined $_ && $DEBUG;
my $lineNo = 1;
READ_SUBS:
while (defined $_) {
# Each loop iteration reads one subtitle from <IN>
my $sub = {};
# print STDERR "Reading line $lineNo\n" if $DEBUG;
# Skip empty lines
while (/^\s*$/) {
last READ_SUBS if ! ($_ = <IN>);
++$lineNo;
}
# Subtitle number
if (/^\s*([0-9]+)\s*$/) {
$sub -> {srtNumber} = $1;
# print "SRT num: $1\n" if $DEBUG;
} else {
die "Invalid SRT format at line $lineNo";
}
# Timing
if ($_ = <IN>) {
++$lineNo;
} else {
die "Unexpected end of SRT stream at line $lineNo";
}
# print STDERR "LINE: $_\n" if $DEBUG;
if (/^\s*(\S+)\s*--\>\s*(\S+)\s*$/) {
my $startMillis = getTimeMillis ($1);
my $endMillis = getTimeMillis ($2);
die "Invalid SRT timing format at line $lineNo: $_"
if ! defined $startMillis || ! defined $endMillis;
$sub -> {srtStartTime} = $startMillis;
$sub -> {srtEndTime} = $endMillis;
} else {
die "Invalid SRT timing format at line $lineNo: $_";
}
# Text lines
my $subLines = [];
while (1) {
last if ! ($_ = <IN>); # EOF ends subtitle
++$lineNo;
last if /^\s*$/; # Empty line ends subtitle
($_ = $_) =~ s/\s+$//; # Strip trailing spaces
push @{$subLines}, $_;
}
die "No text in SRT subtitle at line $lineNo" if 0 == scalar @{$subLines};
$sub -> {lines} = $subLines;
# Append subtitle to the list
push @{$subs}, $sub;
}
print STDERR "SRT read ok, $lineNo lines\n" if $DEBUG;
return $subs;
}
# Write SRT subtitles
sub writeSRT
{
use integer; # For integer division
local *OUT = shift;
my $subs = shift;
my $subNum = 0;
foreach (@{$subs}) {
++$subNum;
my $sub = $_;
my $sTimeSRT = getTimeSRT ($sub -> {srtStartTime});
my $eTimeSRT = getTimeSRT ($sub -> {srtEndTime});
printf OUT ("%d\n%s --> %s\n", $subNum, $sTimeSRT, $eTimeSRT);
foreach (@{$sub -> {lines}}) {
printf OUT ("%s\n", $_);
}
printf OUT "\n";
}
printf STDERR ("Wrote %d SRT subs\n", $subNum) if $DEBUG;
}
# Shift SRT subtitles by a given number of seconds.
# The number may be negative and fractional.
sub shiftSRT
{
use integer; # $shiftMilli could be passed as float
my $subs = shift;
my $shiftMilli = shift;
foreach (@{$subs}) {
$_ -> {srtStartTime} += $shiftMilli;
$_ -> {srtEndTime} += $shiftMilli;
}
}
# Multiply each subtitle timing by a divident and divide by divisor.
# The idea is that the divident is usually the new total number of
# milliseconds in the subtitle file, and the divisor is the old
# total number of milliseconds in the subtitle file.
# We could simply use a double precision real coefficient instead of
# integer divident and divisor, and that could be good enough, but
# using integer arithmetics *guarantees* precision up to the last
# digit, so why settle for good enough when we can have a guarantee.
#
# Uses Math::BigInt arithmetics, because it works with numbers
# up to (total number of milliseconds for a subtitle timing)^2,
# which could be on the order of approximately 1e+13, which is
# larger than maximum 32-bit integer.
# There is a performance loss when using BigInt vs. regular floating
# point arithmetics, but the actual performance is quite acceptable
# on files with a few thousand subtitles.
sub scaleSRT
{
use integer; # Divident and divisor could be passed as floats, truncate
my $subs = shift;
my $scaleDividend = shift;
my $scaleDivisor = shift;
foreach (@{$subs}) {
my $ss = Math::BigInt -> new ($_ -> {srtStartTime});
$ss = $ss -> bmul ($scaleDividend);
$_ -> {srtStartTime} = $ss -> bdiv ($scaleDivisor) -> bsstr ();
my $se = Math::BigInt -> new ($_ -> {srtEndTime});
$se = $se -> bmul ($scaleDividend);
$_ -> {srtEndTime} = $se -> bdiv ($scaleDivisor) -> bsstr ();
}
}
# Extract a fragment within a given time interval
# Either "from" or "to" may be undefined
sub splitSRT
{
use integer; # fromMilli and toMilli could be passed as floats, truncate
my $subs = shift;
my $fromMilli = shift;
my $toMilli = shift;
my $iSub = 0;
while ($iSub < scalar @{$subs}) {
$_ = $subs -> [$iSub];
my $keep = 0;
if (! defined $fromMilli || $_ -> {srtEndTime} >= $fromMilli) {
# The subtitle ends later than the start boundary
# Fix overlapping start timing,
# but only of the start boundary is not infinite (undef)
if (defined $fromMilli && $_ -> {srtStartTime} < $fromMilli) {
$_ -> {srtStartTime} = $fromMilli;
}
if (! defined $toMilli || $_ -> {srtStartTime} <= $toMilli) {
# The subtitle begins earlier than the end boundary
# Fix overlapping end timing,
# but only of the end boundary is not infinite (undef)
if (defined $toMilli && $_ -> {srtEndTime} > $toMilli) {
$_ -> {srtEndTime} = $toMilli;
}
# All conditions met, all fixes done
$keep = 1;
}
}
if ($keep) {
++$iSub;
} else {
splice @{$subs}, $iSub, 1;
}
}
}
# Print brief usage help
# Accepts an optional error message, e.g. for errors parsing command line
sub usage
{
my $msg = shift;
my $exitCode = 0;
if (defined $msg) {
$exitCode = 2;
print STDERR "$msg\n";
}
print STDERR <<USAGE;
Usage: $0 [switches]
-if,--input-format <fmt> input format; supported: SRT
default is SRT
-of,--output-format <fmt> output format; supported: SRT
default is same as input format
-s,--shift <time> shift all subtitles by <time>
(format: [-]hh:mm:ss,fraction)
-c,--scale <time> scale by adding <time> to overall duration
-f,--split-from <time> Drop subtitles that end before <time>
-t,--split-to <time> Drop subtitles that start after <time>
(will truncate timing if it overlaps a boundary)
-r,--renumber renumber SRT subtitles in output
-d,--debug enable debug output
-h,--help this help message
All times could be negative. Input/output may also contain negative timings,
which is sometimes useful for intermediate results.
SRT subtitles are always renumbered on output.
EXAMPLES
Split subtitle file into two disks at a boundary of one hour 15 minutes:
subedit.pl --split-to 1:15:0 < all.srt > p1.srt
subedit.pl -f 1:15:0 < all.srt | subedit.pl --shift -1:15:0 > p2.srt
Join the previous two disks back into one file:
subedit.pl -s 1:15:00 < p2.srt | cat p1.srt - | subedit.pl > all.srt
Correct a situation where the first subtitle starts in sync with the video,
but the last one starts 3.5 seconds earlier than the speech in the video,
assuming the first subtitle timing is 00:01:05.030:
subedit.pl -s -1:5.03 | subedit.pl -c 3.5 | subedit.pl -s 1:5.03
USAGE
exit $exitCode;
}

View File

@ -1,237 +0,0 @@
/*
* Use with CVS JOCR/GOCR.
*
* You will have to change 'vobsub_id' value if you want another subtitle than number 0.
*
* HINT: you can view the subtitle that is being decoded with "display subtitle-*.pgm"
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* Make sure this accesses the CVS version of JOCR/GOCR */
#define GOCR_PROGRAM "gocr"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "libvo/video_out.h"
#include "sub/vobsub.h"
#include "sub/spudec.h"
/* linking hacks */
char *mplayer_version;
/* XXX Kludge ahead, this MUST be the same as the definitions found in ../spudec.c */
typedef struct packet_t packet_t;
struct packet_t {
unsigned char *packet;
unsigned int palette[4];
unsigned int alpha[4];
unsigned int control_start; /* index of start of control data */
unsigned int current_nibble[2]; /* next data nibble (4 bits) to be
processed (for RLE decoding) for
even and odd lines */
int deinterlace_oddness; /* 0 or 1, index into current_nibble */
unsigned int start_col, end_col;
unsigned int start_row, end_row;
unsigned int width, height, stride;
unsigned int start_pts, end_pts;
packet_t *next;
};
typedef struct {
packet_t *queue_head;
packet_t *queue_tail;
unsigned int global_palette[16];
unsigned int orig_frame_width, orig_frame_height;
unsigned char* packet;
size_t packet_reserve; /* size of the memory pointed to by packet */
unsigned int packet_offset; /* end of the currently assembled fragment */
unsigned int packet_size; /* size of the packet once all fragments are assembled */
unsigned int packet_pts; /* PTS for this packet */
unsigned int palette[4];
unsigned int alpha[4];
unsigned int cuspal[4];
unsigned int custom;
unsigned int now_pts;
unsigned int start_pts, end_pts;
unsigned int start_col, end_col;
unsigned int start_row, end_row;
unsigned int width, height, stride;
size_t image_size; /* Size of the image buffer */
unsigned char *image; /* Grayscale value */
unsigned char *aimage; /* Alpha value */
unsigned int scaled_frame_width, scaled_frame_height;
unsigned int scaled_start_col, scaled_start_row;
unsigned int scaled_width, scaled_height, scaled_stride;
size_t scaled_image_size;
unsigned char *scaled_image;
unsigned char *scaled_aimage;
int auto_palette; /* 1 if we lack a palette and must use an heuristic. */
int font_start_level; /* Darkest value used for the computed font */
const vo_functions_t *hw_spu;
int spu_changed;
} spudec_handle_t;
int vobsub_id=0;
int sub_pos=0;
static spudec_handle_t *spudec;
static FILE *fsub = NULL;
static unsigned int sub_idx = 0;
static void
process_gocr_output(const char *const fname, unsigned int start, unsigned int end)
{
FILE *file;
int temp, h, m, s, ms;
int c, bol;
file = fopen(fname, "r");
if (file == NULL) {
perror("fopen failed");
return;
}
temp = start;
temp /= 90;
h = temp / 3600000;
temp %= 3600000;
m = temp / 60000;
temp %= 60000;
s = temp / 1000;
temp %= 1000;
ms = temp;
fprintf(fsub, "%d\n%02d:%02d:%02d,%03d --> ", ++sub_idx, h, m, s, ms);
temp = end;
temp /= 90;
h = temp / 3600000;
temp %= 3600000;
m = temp / 60000;
temp %= 60000;
s = temp / 1000;
temp %= 1000;
ms = temp;
fprintf(fsub, "%02d:%02d:%02d,%03d\n", h, m, s, ms);
bol = 1;
while ((c = getc(file)) != EOF) {
if (bol) {
if (!isspace(c)) {
putc(c, fsub);
bol=0;
}
}
else if (!bol) {
putc(c, fsub);
bol = c == '\n';
}
}
putc('\n', fsub);
fflush(fsub);
fclose(file);
}
static void
output_pgm(FILE *f, int w, int h, unsigned char *src, unsigned char *srca, int stride)
{
int x, y;
fprintf(f,
"P5\n"
"%d %d\n"
"255\n",
w, h);
for (y = 0; y < h; ++y) {
for (x = 0; x < w; ++x) {
int res;
if (srca[x])
res = src[x] * (256 - srca[x]);
else
res = 0;
res = (65535 - res) >> 8;
putc(res&0xff, f);
}
src += stride;
srca += stride;
}
putc('\n', f);
}
static void
draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
{
FILE *f;
char buf[128];
char cmd[512];
int cmdres;
const char *const tmpfname = tmpnam(NULL);
sprintf(buf, "subtitle-%d-%d.pgm", spudec->start_pts / 90, spudec->end_pts / 90);
f = fopen(buf, "w");
output_pgm(f, w, h, src, srca, stride);
fclose(f);
/* see <URL:http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/subtitleripper/subtitleripper/src/README.gocr?rev=HEAD&content-type=text/vnd.viewcvs-markup> */
sprintf(cmd, GOCR_PROGRAM" -v 1 -s 7 -d 0 -m 130 -m 256 -m 32 -i %s -o %s", buf, tmpfname);
cmdres = system(cmd);
if (cmdres < 0) {
perror("system failed");
exit(EXIT_FAILURE);
}
else if (cmdres) {
fprintf(stderr, GOCR_PROGRAM" returned %d\n", cmdres);
exit(cmdres);
}
process_gocr_output(tmpfname, spudec->start_pts, spudec->end_pts);
unlink(buf);
unlink(tmpfname);
}
int
main(int argc, char **argv)
{
const char *vobsubname, *subripname;
void *vobsub;
void *packet;
int packet_len;
unsigned int pts100;
if (argc < 2 || 4 < argc) {
fprintf(stderr, "Usage: %s <vobsub basename> [<subid> [<output filename>] ]\n", argv[0]);
exit(EXIT_FAILURE);
}
vobsubname = argv[1];
subripname = NULL;
fsub = stdout;
if (argc >= 3)
vobsub_id = atoi(argv[2]);
if (argc >= 4) {
subripname = argv[3];
fsub = fopen(subripname, "w");
}
vobsub = vobsub_open(vobsubname, NULL, 0, &spudec);
while ((packet_len=vobsub_get_next_packet(vobsub, &packet, &pts100)) >= 0) {
spudec_assemble(spudec, packet, packet_len, pts100);
if (spudec->queue_head) {
spudec_heartbeat(spudec, spudec->queue_head->start_pts);
if (spudec_changed(spudec))
spudec_draw(spudec, draw_alpha);
}
}
if (vobsub)
vobsub_close(vobsub);
exit(EXIT_SUCCESS);
}

View File

@ -1,34 +0,0 @@
#!/bin/sh
#
# Collects all the appropriate subtitle files in a given directory and
# its subdirectories, no matter what the filename is.
# Use this together as: mplayer -sub `subsearch.sh` movie
# Author: Alex
#
[ $1 ] && cd `dirname $1`
_sub_names=""
one_dir_search() {
for i in $dir/*
do
case "`echo $i | tr [:upper:] [:lower:]`" in
*.sub|*.srt|*.mps|*.txt) _sub_names="$i,$_sub_names" ;;
*) ;;
esac
done
}
dir="."
one_dir_search
# add subdirectories too
for dir in *
do
[ -d $dir ] && one_dir_search
done
_len="`echo $_sub_names | wc -c`"
_len=$((_len-2))
echo $_sub_names | cut -b -"$_len"

View File

@ -1,304 +0,0 @@
/*
* VFW Compressor Settings Tool
*
* Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
*
* Official Website : http://oss.netfarm.it/mplayer-win32.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* On MinGW compile with: gcc vfw2menc.c -o vfw2menc.exe -lwinmm -lole32 */
/* Using Wine: winegcc vfw2menc.c -o vfw2menc -lwinmm -lole32 */
/* MSVC requires getopt.c and getopt.h available at the original website */
#ifdef _MSC_VER
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable: 4996)
#endif
#define VERSION "0.1"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <getopt.h>
#include <windows.h>
#include <vfw.h>
#define BAIL(msg) { printf("%s: %s\n", argv[0], msg); ret = -1; goto cleanup; }
typedef struct {
UINT uDriverSignature;
HINSTANCE hDriverModule;
DRIVERPROC DriverProc;
DWORD dwDriverID;
} DRVR;
typedef DRVR *PDRVR;
typedef DRVR *NPDRVR;
typedef DRVR *LPDRVR;
enum
{
MODE_NONE = 0,
MODE_CHECK,
MODE_SAVE,
MODE_VIEW
};
static int save_settings(HDRVR hDriver, const char *filename)
{
FILE *fd = NULL;
DWORD cb = (DWORD) SendDriverMessage(hDriver, ICM_GETSTATE, 0, 0);
char *pv = NULL;
if (!cb)
{
printf("ICM_GETSTATE returned 0 size\n");
return -1;
}
pv = malloc(cb);
if (SendDriverMessage(hDriver, ICM_GETSTATE, (LPARAM) pv, (LPARAM) &cb) != ICERR_OK)
{
printf("ICM_GETSTATE failed\n");
free(pv);
return -1;
}
fd = fopen(filename, "wb");
if (!fd)
{
printf("Cannot open file %s for writing\n", filename);
free(pv);
return -1;
}
if (fwrite(pv, cb, 1, fd) != 1)
{
printf("fwrite() failed on %s\n", filename);
free(pv);
fclose(fd);
return -1;
}
fclose(fd);
free(pv);
return 0;
}
static int load_settings(HDRVR hDriver, const char *filename)
{
struct stat info;
FILE *fd = NULL;
char *pv;
if (stat(filename, &info) < 0)
{
printf("stat() on %s failed\n", filename);
return -1;
}
pv = malloc(info.st_size);
fd = fopen(filename, "rb");
if (!fd)
{
printf("Cannot open file %s for reading\n", filename);
free(pv);
return -1;
}
if (fread(pv, info.st_size, 1, fd) != 1)
{
printf("fread() failed on %s\n", filename);
free(pv);
fclose(fd);
return -1;
}
fclose(fd);
if (!SendDriverMessage(hDriver, ICM_SETSTATE, (LPARAM) pv, (LPARAM) info.st_size))
{
printf("ICM_SETSTATE failed\n");
free(pv);
return -1;
}
free(pv);
return 0;
}
static struct option long_options[] =
{
{ "help", no_argument, NULL, 'h' },
{ "driver", required_argument, NULL, 'd' },
{ "fourcc", required_argument, NULL, 'f' },
{ "save", required_argument, NULL, 's' },
{ "check", required_argument, NULL, 'c' },
{ "view", no_argument, NULL, 'v' },
{ 0, 0, 0, 0 }
};
static void help(const char *progname)
{
printf("VFW to mencoder v"VERSION" - Copyright 2007 - Gianluigi Tiesi <sherpya@netfarm.it>\n");
printf("This program is Free Software\n\n");
printf("Usage: %s\n", progname);
printf(" -h|--help - displays this help\n");
printf(" -d|--driver filename - dll or drv to load\n");
printf(" -f|--fourcc fourcc - fourcc of selected driver (look at codecs.conf)\n");
printf(" -s|--save filename - save settings to file\n");
printf(" -c|--check filename - load and show setting in filename\n");
printf(" -v|--view - displays the config dialog and do nothing\n");
printf("\nExamples:\n");
printf(" %s -f VP62 -d vp6vfw.dll -s firstpass.mcf\n", progname);
printf(" %s -f VP62 -d vp6vfw.dll -c firstpass.mcf\n", progname);
printf(" %s -f VP62 -d vp6vfw.dll -v\n", progname);
printf("\nIf the driver dialog doesn't work, you can try without specifing a fourcc,\n");
printf("but the compdata file will not work with mencoder.\n");
printf("Driver option is required and you must specify at least -s, -c -o -v\n");
printf("Usage with mencoder -ovc vfw -xvfwopts codec=vp6vfw.dll:compdata=settings.mcf\n");
}
int main(int argc, char *argv[])
{
char *driver = NULL;
char *fourcc = NULL;
char *filename = NULL;
unsigned char mode = 0;
DWORD dwFCC = 0;
ICOPEN icopen;
HRESULT coinit = -1;
/* ICINFO icinfo; */
wchar_t drvfile[MAX_PATH];
HDRVR hDriver = NULL;
int ret = 0;
int c = -1, long_options_index = -1;
if (argc < 2)
{
help(argv[0]);
ret = -1;
goto cleanup;
}
while ((c = getopt_long(argc, argv, "hd:f:s:c:v", long_options, &long_options_index)) != -1)
{
switch (c)
{
case 'h':
help(argv[0]);
ret = 0;
goto cleanup;
case 'd':
driver = strdup(optarg);
break;
case 'f':
fourcc = strdup(optarg);
if (strlen(optarg) != 4) BAIL("Fourcc must be exactly 4 chars");
break;
case 's':
if (mode != MODE_NONE) BAIL("Incompatible arguments");
filename = strdup(optarg);
mode = MODE_SAVE;
break;
case 'c':
if (mode != MODE_NONE) BAIL("Incompatible arguments");
filename = strdup(optarg);
mode = MODE_CHECK;
break;
case 'v':
if (mode != MODE_NONE) BAIL("Incompatible arguments");
mode = MODE_VIEW;
break;
default:
printf("Wrong arguments!\n");
help(argv[0]);
goto cleanup;
}
}
if (!(argc == optind) && (mode != MODE_NONE) &&
driver && (filename || (mode == MODE_VIEW)))
{
help(argv[0]);
goto cleanup;
}
if (!MultiByteToWideChar(CP_ACP, 0, driver, -1, drvfile, MAX_PATH))
BAIL("MultiByteToWideChar() failed\n");
if (fourcc) memcpy(&dwFCC, fourcc, 4);
memset(&icopen, 0, sizeof(icopen));
icopen.dwSize = sizeof(icopen);
icopen.fccType = ICTYPE_VIDEO; /* VIDC */
icopen.fccHandler = dwFCC;
icopen.dwVersion = 0x00001000; /* FIXME */
icopen.dwFlags = ICMODE_COMPRESS;
icopen.dwError = 0;
icopen.pV1Reserved = NULL;
icopen.pV2Reserved = NULL;
icopen.dnDevNode = -1; /* FIXME */
coinit = CoInitialize(NULL);
if (!(hDriver = OpenDriver(drvfile, NULL, (LPARAM) &icopen)))
BAIL("OpenDriver() failed\n");
/*
memset(&icinfo, 0, sizeof(ICINFO));
icinfo.dwSize = sizeof(ICINFO);
SendDriverMessage(hDriver, ICM_GETINFO, (LPARAM) &icinfo, sizeof(ICINFO));
*/
if (SendDriverMessage(hDriver, ICM_CONFIGURE, -1, 0) != ICERR_OK)
BAIL("The driver doesn't provide a configure dialog");
switch(mode)
{
case MODE_CHECK:
if (load_settings(hDriver, filename))
BAIL("Cannot load settings from file");
if (SendDriverMessage(hDriver, ICM_CONFIGURE, 0, 0) != ICERR_OK)
BAIL("ICM_CONFIGURE failed");
break;
case MODE_SAVE:
if (SendDriverMessage(hDriver, ICM_CONFIGURE, 0, 0) != ICERR_OK)
BAIL("ICM_CONFIGURE failed");
if (save_settings(hDriver, filename))
BAIL("Cannot save settings to file");
break;
case MODE_VIEW:
{
HWND hwnd = GetDesktopWindow();
if (SendDriverMessage(hDriver, ICM_CONFIGURE, (LPARAM) hwnd, 0) != ICERR_OK)
BAIL("ICM_CONFIGURE failed");
}
break;
default:
BAIL("This should not happen :)");
}
cleanup:
free(driver);
free(fourcc);
free(filename);
if (hDriver) CloseDriver(hDriver, 0, 0);
if ((coinit == S_OK) || coinit == S_FALSE) CoUninitialize();
return ret;
}

View File

@ -1,314 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "loader/wine/mmreg.h"
#include "loader/wine/vfw.h"
#include "stream/stream.h"
#include "libmpdemux/muxer.h"
#include "libmpdemux/demuxer.h"
/* linking hacks */
char *info_name;
char *info_artist;
char *info_genre;
char *info_subject;
char *info_copyright;
char *info_sourceform;
char *info_comment;
char* out_filename = NULL;
char* force_fourcc=NULL;
char* passtmpfile="divx2pass.log";
static const short h263_format[8][2] = {
{ 0, 0 },
{ 128, 96 },
{ 176, 144 },
{ 352, 288 },
{ 704, 576 },
{ 1408, 1152 },
{ 320, 240 }
};
unsigned char* buffer;
int bufptr=0;
int bitcnt=0;
unsigned char buf=0;
static unsigned int x_get_bits(int n){
unsigned int x=0;
while(n-->0){
if(!bitcnt){
// fill buff
buf=buffer[bufptr++];
bitcnt=8;
}
//x=(x<<1)|(buf&1);buf>>=1;
x=(x<<1)|(buf>>7);buf<<=1;
--bitcnt;
}
return x;
}
#define get_bits(xxx,n) x_get_bits(n)
#define get_bits1(xxx) x_get_bits(1)
#define skip_bits(xxx,n) x_get_bits(n)
#define skip_bits1(xxx) x_get_bits(1)
int format;
int width=320;
int height=240;
/* most is hardcoded. should extend to handle all h263 streams */
static int h263_decode_picture_header(unsigned char *b_ptr)
{
int i;
for(i=0;i<16;i++) printf(" %02X",b_ptr[i]); printf("\n");
buffer=b_ptr;
bufptr=bitcnt=buf=0;
/* picture header */
if (get_bits(&s->gb, 22) != 0x20){
printf("bad picture header\n");
return -1;
}
skip_bits(&s->gb, 8); /* picture timestamp */
if (get_bits1(&s->gb) != 1){
printf("bad marker\n");
return -1; /* marker */
}
if (get_bits1(&s->gb) != 0){
printf("bad h263 id\n");
return -1; /* h263 id */
}
skip_bits1(&s->gb); /* split screen off */
skip_bits1(&s->gb); /* camera off */
skip_bits1(&s->gb); /* freeze picture release off */
format = get_bits(&s->gb, 3);
if (format != 7) {
printf("h263_plus = 0 format = %d\n",format);
/* H.263v1 */
width = h263_format[format][0];
height = h263_format[format][1];
printf("%d x %d\n",width,height);
// if (!width) return -1;
printf("pict_type=%d\n",get_bits1(&s->gb));
printf("unrestricted_mv=%d\n",get_bits1(&s->gb));
#if 1
printf("SAC: %d\n",get_bits1(&s->gb));
printf("advanced prediction mode: %d\n",get_bits1(&s->gb));
printf("PB frame: %d\n",get_bits1(&s->gb));
#else
if (get_bits1(&s->gb) != 0)
return -1; /* SAC: off */
if (get_bits1(&s->gb) != 0)
return -1; /* advanced prediction mode: off */
if (get_bits1(&s->gb) != 0)
return -1; /* not PB frame */
#endif
printf("qscale=%d\n",get_bits(&s->gb, 5));
skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
} else {
printf("h263_plus = 1\n");
/* H.263v2 */
if (get_bits(&s->gb, 3) != 1){
printf("H.263v2 A error\n");
return -1;
}
if (get_bits(&s->gb, 3) != 6){ /* custom source format */
printf("custom source format\n");
return -1;
}
skip_bits(&s->gb, 12);
skip_bits(&s->gb, 3);
printf("pict_type=%d\n",get_bits(&s->gb, 3) + 1);
// if (s->pict_type != I_TYPE &&
// s->pict_type != P_TYPE)
// return -1;
skip_bits(&s->gb, 7);
skip_bits(&s->gb, 4); /* aspect ratio */
width = (get_bits(&s->gb, 9) + 1) * 4;
skip_bits1(&s->gb);
height = get_bits(&s->gb, 9) * 4;
printf("%d x %d\n",width,height);
//if (height == 0)
// return -1;
printf("qscale=%d\n",get_bits(&s->gb, 5));
}
/* PEI */
while (get_bits1(&s->gb) != 0) {
skip_bits(&s->gb, 8);
}
// s->f_code = 1;
// s->width = width;
// s->height = height;
return 0;
}
int postable[32768];
int main(int argc,char ** argv){
int c;
FILE *f;
FILE *f2;
muxer_t* avi;
muxer_stream_t* mux;
//unsigned char* buffer=malloc(0x200000);
int i,len;
int v_id=0;
int flag2=0;
int prefix=0;
// check if enough args were given
if ( argc < 3 ){
printf("Too few arguments given!\n"
"Usage: %s <input_file> <output_file>\n", argv[0]);
return -1;
}
// input
if(!(f=fopen(argv[1],"rb"))){
printf("Couldn't open input file.\n");
return -1;
}
// output
if(!(f2=fopen(argv[2],"wb"))){
printf("Couldn't open output file.\n");
return -1;
}
avi=muxer_new_muxer(MUXER_TYPE_AVI,f2);
mux=muxer_new_stream(avi,MUXER_TYPE_VIDEO);
mux->buffer_size=0x200000;
mux->buffer=malloc(mux->buffer_size);
mux->h.dwScale=1;
mux->h.dwRate=10;
mux->bih=malloc(sizeof(*mux->bih));
mux->bih->biSize=sizeof(*mux->bih);
mux->bih->biPlanes=1;
mux->bih->biBitCount=24;
mux->bih->biCompression=0x6f766976;// 7669766f;
muxer_write_header(avi);
/*
c=fgetc(f); if(c) printf("error! not vivo file?\n");
len=0;
while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F);
len+=c;
printf("hdr1: %d\n",len);
for(i=0;i<len;i++) fgetc(f);
*/
while((c=fgetc(f))>=0){
printf("%08lX %02X\n",ftell(f),c);
prefix=0;
if(c==0x82){
prefix=1;
//continue;
c=fgetc(f);
printf("%08lX %02X\n",ftell(f),c);
}
if(c==0x00){
// header
int len=0;
while((c=fgetc(f))>=0x80) len+=0x80*(c&0x0F);
len+=c;
printf("header: 00 (%d)\n",len);
for(i=0;i<len;i++) fgetc(f);
continue;
}
if((c&0xF0)==0x40){
// audio
len=24;
if(prefix) len=fgetc(f);
printf("audio: %02X (%d)\n",c,len);
for(i=0;i<len;i++) fgetc(f);
continue;
}
if((c&0xF0)==0x30){
// audio
len=40;
if(prefix) len=fgetc(f);
printf("audio: %02X (%d)\n",c,len);
for(i=0;i<len;i++) fgetc(f);
continue;
}
if(flag2 || (((c&0xF0)==0x10 || (c&0xF0)==0x20) && (c&0x0F)!=(v_id&0xF))){
// end of frame:
printf("Frame size: %d\n",mux->buffer_len);
h263_decode_picture_header(mux->buffer);
muxer_write_chunk(mux,mux->buffer_len,0x10, MP_NOPTS_VALUE, MP_NOPTS_VALUE);
mux->buffer_len=0;
if((v_id&0xF0)==0x10) fprintf(stderr,"hmm. last video packet %02X\n",v_id);
}
flag2=0;
if((c&0xF0)==0x10){
// 128 byte
len=128;
if(prefix) len=fgetc(f);
printf("video: %02X (%d)\n",c,len);
fread(mux->buffer+mux->buffer_len,len,1,f);
mux->buffer_len+=len;
v_id=c;
continue;
}
if((c&0xF0)==0x20){
int len=fgetc(f);
printf("video: %02X (%d)\n",c,len);
fread(mux->buffer+mux->buffer_len,len,1,f);
mux->buffer_len+=len;
flag2=1;
v_id=c;
continue;
}
printf("error: %02X!\n",c);
exit(1);
}
if(!width) width=320;
if(!height) height=240;
mux->bih->biWidth=width;
mux->bih->biHeight=height;
mux->bih->biSizeImage=3*width*height;
muxer_write_index(avi);
fseek(f2,0,SEEK_SET);
muxer_write_header(avi);
return 0;
}

View File

@ -1,58 +0,0 @@
#!/usr/bin/env python
#usage:
#
# vobshift.py in.idx out.idx -8.45
#
# this will read in in.idx,shift it by 8.45 seconds back,
# and save it as out.idx
#
# license: i don't care ;)
#
import datetime
import sys
def tripletize(line):
begin = line[:11]
middle = line[11:23]
end = line[23:]
return (begin,middle,end)
def text2delta(t):
h = int( t[0:2] )
m = int( t[3:5] )
s = int( t[6:8] )
milli = int( t[9:12] )
return datetime.timedelta(hours=h,minutes=m,seconds=s,milliseconds=milli)
def delta2text(d):
t = str(d)
milli = t[8:11]
if len(milli) == 0: #fix for .000 seconds
milli = '000'
return '0'+t[:7]+':'+milli
def shift(line,seconds):
triplet = tripletize(line)
base = text2delta(triplet[1])
base = base + datetime.timedelta(seconds=seconds)
base = delta2text(base)
return triplet[0]+base+triplet[2]
INFILE =sys.argv[1]
OUTFILE =sys.argv[2]
DIFF =float(sys.argv[3])
o = open(OUTFILE,'wt')
for line in open(INFILE):
if line.startswith('timestamp'):
line = shift(line,DIFF)
o.write(line)
o.close()

View File

@ -1,168 +0,0 @@
#!/usr/bin/perl
## usage: w32codec_dl.pl (codec.conf location)
# this script will use MS's codec dl interface as used by MS Media Player
# to attempt to locate the codecs listed in codecs.conf. It will download
# them to a directory "codecs/" below the current dir.
# you will need the libwww-perl stuff and the utility "cabextract"
# which may be found at http://www.kyz.uklinux.net/cabextract.php3
# By Tom Lees, 2002. I hereby place this script into the public domain.
#use LWP::Debug qw(+);
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent ("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
# Parse the etc/codecs.conf file
my $cconf = $ARGV[0];
open CCONF, "<$cconf";
my $codec = "(none)";
my $mscodec = 0;
my $cc, @ccl;
mkdir "codecs";
chdir "codecs";
CC: while (<CCONF>)
{
next CC if (m/^[ \t]*\;/);
s/\;.*//g;
s/#.*//g;
if (m/^videocodec (.*)/)
{
$codec = $1;
}
elsif (m/^[ \t]+driver (.*)/)
{
if ($1 eq "dshow" || $1 eq "vfw")
{
$mscodec = 1;
}
else
{
$mscodec = 0;
}
}
elsif (m/^[ \t]+fourcc (.*)/ && $mscodec == 1)
{
$cclist = $1;
chomp $cclist;
#@ccl = ();
do
{
if ($cclist =~ m/\"(....)\"[, ]*(.*)/)
{
$cc = $1;
$cclist = $2;
}
elsif ($cclist =~ m/[, ]*(....)[, ]*(.*)/)
{
$cc = $1;
$cclist = $2;
}
else
{
$cc = $cclist;
$cclist = "";
}
if (!($cc =~ m/^[ \t]+/))
{
push @ccl, ($cc);
}
} while (length ($cclist) > 0);
}
}
close CCONF;
# Find the codecs
open CODEC_CABS, ">codecs.locations.info";
%fcc_try = ();
while ($#ccl > 0)
{
$cc = pop (@ccl);
if (!$fcc_try{"$cc"})
{
$fcc_try{"$cc"} = 1;
if (!find_codec ($cc))
{
print "$cc found\n";
}
else
{
print "MS didn't find $cc\n";
}
}
}
close CODEC_CABS;
%got_codecs = ();
sub find_codec
{
my ($fourcc) = @_;
my $guid = sprintf ("%08X", unpack ("V", $fourcc))."-0000-0010-8000-00AA00389B71";
my $req = HTTP::Request->new (POST => "http://activex.microsoft.com/objects/ocget.dll");
$req->header ('Accept', '*/*');
$req->content_type ('application/x-www-form-urlencoded');
$req->content ("CLSID=%7B${guid}%7D\n");
#$req->content ('CLSID={'.${guid}.'}');
my $res = $ua->request ($req);
if ($res->is_success) {
print "Lookup returned success... weird!\n";
return 1;
} else {
# Codec location
if ($res->code == 302)
{
my $loc = $res->headers->header ("Location");
if (!$got_codecs{"$loc"})
{
print CODEC_CABS "$loc\n";
$got_codecs{"$loc"} = 1;
get_codec ($loc);
}
# else
# {
# print "Already have $loc\n";
# }
return 0;
}
else
{
# print "Lookup failed (Microsoft probably doesn't know this codec)\n";
return 1;
}
}
}
sub get_codec
{
my ($url) = @_;
my $req = HTTP::Request->new (GET => $url);
$req->header ("Accept", "*/*");
my $res = $ua->request ($req);
if ($res->is_success)
{
open TMP, ">tmp.cab" or die "Unable to open tmp.cab";
print TMP $res->content;
close TMP;
system "cabextract tmp.cab";
unlink "tmp.cab";
}
else
{
print "No such file!\n";
}
}

View File

@ -1,340 +0,0 @@
#!/usr/bin/perl
#################################
# wma converter 0.3.6 for Linux #
#################################
# Made by Peter Simon <simon.peter@linuxuser.hu>
# License: GNU GPL
#
# Needed programs:
#
# Getopt::Long - Perl Module
# MPlayer - http://www.mplayerhq.hu
# BladeEnc - http://bladeenc.mp3.no
# oggenc - http://www.vorbis.com
# mp3info - http://www.ibiblio.org/mp3info
# changelog:
# 0.1.0
# decoding all files to wav without any switches and encoders
# 0.2.0
# converting to mp3 or ogg with bitrate, delete options
# 0.2.1
# L.A.M.E. support for fanatics
# Default output filetype: ogg
# Some error warnings
# 0.3.0
# Reading the wma tags out and puting into the mp3 or the ogg tags. (What the MPlayer shows of those.)
# Default output bitrate: the original bitrate
# Simlink for the default encode mode (wma2ogg = ogg, wma2mp3 = mp3)
# 0.3.1
# Neglecting missing encoders if those are not in use.
# 0.3.2
# Using mp3info for the mp3 tags
# 0.3.3
# Convert more then one files in the start dir.
# 0.3.4-5
# Some bugfixes.
# 0.3.6
# Some bugfixes by Diego Biurrun
# Why BladeEnc?
# Eg.: The L.A.M.E.'s code isn't compatible for some hardwer-decoders. Makes noise and clashings.
# I never met this trouble using BladeEnc.
# That's it.
use Getopt::Long qw(:config pass_through);
$ver="0.3.6";
GetOptions("help|?",\&showhelp, 'a' => \$all, "file|f=s" => \@files,"t=s" => \$mtype, "lame" => \$needlame, "del" => \$delete, "br=i" => \$sbrate);
if (@ARGV) {
foreach (@ARGV) {
error ("Missing parameter after the $_ switch!");
}
exit;
}
print "wma2ogg $ver\nPeter Simon <simon.peter\@linuxuser.hu>";
if (!$all && !@files) {
error ("There is no selected file!");
exit;
}
if ($0 =~/wma2mp3/ && !$mtype) {
$mtype="mp3";
}
if ($mtype eq "ogg") {
$ttype{"ogg"}="oggenc";
needed_prgs (oggenc, "http://www.vorbis.com");
}
if ($needlame && $mtype eq "ogg") {
error ("\nYou can not use L.A.M.E. & oggenc together!\n");
exit;
}
if (!$mtype && !$needlame) {
$mtype="ogg";
$ttype{"ogg"}="oggenc";
needed_prgs (oggenc, "http://www.vorbis.com");
}
if (!$needlame && $mtype eq "mp3") {
$ttype{"mp3"}="BladeEnc";
needed_prgs (BladeEnc, "http://bladeenc.mp3.no", mp3info, "http://www.ibiblio.org/mp3info");
}
if ($needlame) {
$mtype="mp3";
$ttype{"mp3"}="lame";
needed_prgs (lame, "http://lame.sourceforge.net", mp3info, "http://www.ibiblio.org/mp3info");
}
# Main program
print "\nUsing lame - WARNING - this is not optimal!\n";
ch_needed ();
ch_type ();
ch_files ();
decode();
# the end.
sub ch_type {
$o_type=$ttype{$mtype};
if ($mtype ne "wav") {
$def_path=$ENV{PATH};
@exec_path=split /\:/, $def_path;
foreach $temp_path (@exec_path) {
if (-d $temp_path && !$enc_ok) {
$enc_ok=`find $temp_path -name $o_type -type f -maxdepth 1 2>/dev/null`;
chomp ($enc_ok);
}
}
}
if ((!$o_type || !$enc_ok) && $mtype ne "wav") {
error("Unknown encoder.");
exit;
}
}
sub ch_br {
if ($sbrate && ((($sbrate <32 || $sbrate>350) && $mtype eq "mp3") || (($sbrate<64 || $sbrate>500) && $mtype eq "ogg") )) {
error("Invalid, missing or redundant bitrate.");
exit;
}
}
sub ch_files {
if ($all && @files) {
error ("You can't use -a switch and -f together!");
exit;
}
if ($all) {
@enc_files=`ls | grep '.wma'\$`;
foreach (@enc_files) {
chomp $_;
}
}
if (@files) {
@enc_files=@files;
}
}
sub showhelp {
print "\n\nUsage: wma2ogg [OPTIONS] (-f FILE1 | -f FILE2 ... | -a)\n
-f, -file filename
-a converts all wma files in the current directory\n
OPTIONS:
-t output filetype (ogg, mp3) [default=ogg]
-lame I wanna use L.A.M.E. sure enough!
-br bitrate (kb/s) [default=from the wma]
-del remove wma file(s) after the transcoding\n";
print $miss_text;
print "\n$errtext\nExiting program.\n";
}
sub error {
$errtext=@_[0];
showhelp ();
}
sub missing_prg {
$what=$keys;
$that=$needed{$keys};
$miss_text.="\nThe needed \'$what\' program is missing, see: $that!";
}
sub ch_needed {
`perl -e 'use Getopt::Long;' 2>./err`;
open (FILE, "<./err");
while ($sor=<FILE>) {
if ($sor =~ /Can\'t locate/) {
missing_prg ("Getopt::Long", ": your Perl is too old... (uhhh... get a new one!)");
}
}
`rm ./err`;
foreach $keys (keys %needed) {
`$keys 2>./err`;
open (FILE, "<./err");
while ($sor=<FILE>) {
if ($sor =~ /$keys\: command not found/) {
missing_prg ();
$error=1;
}
}
`rm ./err`;
}
close FILE;
if ($error) {
showhelp ();
exit;
}
}
sub get_tags {
my $outfile;
open (FILE, "<./1");
while ($sor=<FILE>) {
$outfile.=$sor;
}
close FILE;
$outfile=~ s/\((\d+\,\d+)\ kbit\)/$1/e;
print "\noriginal bitrate: $1";
$kept_orig_brate=$1;
$kept_orig_brate=~ s/(\d+)/$1/e;
$kept_orig_brate=$1;
if (!$sbrate) {
$brate=$kept_orig_brate;
print " (kept as default)";
} else {
$brate=$sbrate;
print " (new: $brate,0)";
}
ch_br ();
`rm ./1`;
my @temp_info=split /Clip\ info\:/, $outfile;
my @temp2_info=split /\n/, @temp_info[1];
my @temp_title=split /\ /, $temp2_info[1],3;
my @temp_author=split /\ /, $temp2_info[2],3;
my @temp_copyright=split /\ /, $temp2_info[3],3;
my @temp_comments=split /\ /, $temp2_info[4],3;
return ($temp_title[2], $temp_author[2], $temp_copyright[2], $temp2_comments[2]);
}
sub needed_prgs {
%needed=(
$_[0]=>$_[1],
$_[2]=>$_[3],
mplayer=>"http://www.mplayerhq.hu",
);
}
sub mp3_info {
if ($title) {
$infofile=" -t '$title'";
}
if ($author) {
$infofile.=" -a '$author'";
}
if ($comments) {
$infofile.=" -c '$comments'";
}
`mp3info "$p_name.$mtype" $infofile`;
undef ($infofile);
}
sub decode {
foreach (@enc_files) {
$wav_name=$_;
$wav_name=~ s/(.+)\./$1/e;
$p_name=$1;
$wav_name=$p_name.".wav";
$pwd=`pwd`;
chomp $pwd;
$pwd.="/t2";
print "\nConverting $_ to \"wav\" file.\n";
print "Using MPlayer...\n";
`mplayer "$_" -ao pcm -input conf="$pwd" 2>/dev/null >./1`;
`mv "audiodump.wav" "$wav_name"`;
@tags=get_tags ();
$title=$tags[0];
print "\ntitle: $title";
$author=$tags[1];
print "\nauthor: $author";
$copyright=$tags[2];
print "\ncopyright: $copyright";
$comments=$tags[3];
print "\ncomments: $comments";
$comments=$copyright." ".$comments."Transcoded by wma2ogg";
print "\n\nConverting $wav_name to \"$mtype\" file.";
print "\nUsing $o_type...";
if ($mtype eq "ogg") {
$br_sw="b";
if ($title) {
$infofile=" -t '$title'";
}
if ($author) {
$infofile.=" -a '$author'";
}
if ($comments) {
$infofile.=" -c COMMENT='$comments'";
}
`"$o_type" "-$br_sw" "$brate" "-Q" "./$wav_name" $infofile "-o" "$p_name.$mtype"`;
`rm -f "$wav_name"`;
}
if ($mtype eq "mp3" && !$needlame) {
$br_sw="br";
`"$o_type" "$wav_name" "$p_name.$mtype" "-$br_sw" "$brate" 2>/dev/null >/dev/null`;
mp3_info ();
`rm -f "$wav_name"`;
}
if ($mtype eq "mp3" && $needlame) {
$br_sw="b";
`"$o_type" "-$br_sw" "$brate" "-f" "$wav_name" "$p_name.$mtype" 2>/dev/null >/dev/null`;
mp3_info ();
`rm -f "$wav_name"`;
}
if ($delete) {
`rm -f "$_"`;
}
if (-e "./err") {
`rm ./err`;
}
}
print "\n\nDone.\n\n";
}