/* * vcdpad pads VCD MPEGs to be usable by mkvcdfs * * Copyright (C) 2000 Stefan Berndtsson * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * * Thanks to Brian King for finding a solution to the audio blips. * */ #include #include #include #include #include #include #include #define FSIZE 2324 unsigned char buffer[FSIZE*3]; int start,end; int fd; int fill_buffer(int offset) { int size; lseek(fd, offset, SEEK_SET); size = read(fd, buffer, FSIZE*2); start = offset; end = offset + size; if(size != FSIZE*2) return -1; return 0; } int get_byte(int offset) { int endpoint; if((offset >= start) && (offset < end)) return (int) buffer[offset - start]; endpoint = fill_buffer(offset); if(endpoint == -1) return -1; return (int) buffer[0]; } int find_frame(int offset, int totsize) { int i; for(i=offset;i 0) && (block < FSIZE)) { if (block != 2304) { fprintf(stdout, "Block size: %d\n", block); fprintf(stdout, "Writing block of %d bytes\n", block); } pad_count++; sum += FSIZE; write(ofd, buf, block); write(ofd, out, FSIZE-block); lseek(fd, -(FSIZE+(FSIZE-block)), SEEK_CUR); } } } fprintf(stderr, "\nDone padding.\n"); fprintf(stdout, "\nPadded %d blocks\n", pad_count); close(fd); close(ofd); return 0; }