comparison TOOLS/subrip.c @ 10306:b7464c68bef3

Fixed: sync structs with spudec.c, implement fast_memcpy
author kmkaplan
date Wed, 18 Jun 2003 10:08:54 +0000
parents 032137fe69a5
children c6e8ef454266
comparison
equal deleted inserted replaced
10305:3e40b8f879c8 10306:b7464c68bef3
1 /* -*- compile-command: "gcc -g -Wall -I.. -o subrip subrip.c ../vobsub.o ../spudec.o ../mp_msg.o" -*- */ 1 /* -*- compile-command: "gcc -g -Wall -I.. -o subrip subrip.c ../vobsub.o ../spudec.o ../mp_msg.o ../unrarlib.o ../postproc/swscale.o ../postproc/rgb2rgb.o ../postproc/yuv2rgb.o ../libmpcodecs/img_format.o -lm" -*- */
2 /* 2 /*
3 * Use with CVS JOCR/GOCR. 3 * Use with CVS JOCR/GOCR.
4 * 4 *
5 * You will have to change 'vobsub_id' value if you want another subtitle than number 0. 5 * You will have to change 'vobsub_id' value if you want another subtitle than number 0.
6 * 6 *
7 * HINT: you can view the subtitle that is being decoded with "display subtitle-*.pgm" 7 * HINT: you can view the subtitle that is being decoded with "display subtitle-*.pgm"
8 * 8 *
9 */ 9 */
10 10
11 /* Make sure this accesses the CVS version of JOCR/GOCR */ 11 /* Make sure this accesses the CVS version of JOCR/GOCR */
12 #define GOCR_PROGRAM "/usr/local/src/cvs/jocr/jocr/src/gocr" 12 #define GOCR_PROGRAM "gocr"
13 13
14 #include <ctype.h> 14 #include <ctype.h>
15 #include <stdio.h> 15 #include <stdio.h>
16 #include <stdlib.h> 16 #include <stdlib.h>
17 #include <unistd.h> 17 #include <unistd.h>
19 #include <sys/wait.h> 19 #include <sys/wait.h>
20 #include "libvo/video_out.h" 20 #include "libvo/video_out.h"
21 #include "vobsub.h" 21 #include "vobsub.h"
22 #include "spudec.h" 22 #include "spudec.h"
23 23
24 /* XXX Kludge ahead, this MUST be the same as the definition found in ../spudec.c */ 24 /* XXX Kludge ahead, this MUST be the same as the definitions found in ../spudec.c */
25 typedef struct packet_t packet_t;
26 struct packet_t {
27 unsigned char *packet;
28 unsigned int palette[4];
29 unsigned int alpha[4];
30 unsigned int control_start; /* index of start of control data */
31 unsigned int current_nibble[2]; /* next data nibble (4 bits) to be
32 processed (for RLE decoding) for
33 even and odd lines */
34 int deinterlace_oddness; /* 0 or 1, index into current_nibble */
35 unsigned int start_col, end_col;
36 unsigned int start_row, end_row;
37 unsigned int width, height, stride;
38 unsigned int start_pts, end_pts;
39 packet_t *next;
40 };
25 typedef struct { 41 typedef struct {
42 packet_t *queue_head;
43 packet_t *queue_tail;
26 unsigned int global_palette[16]; 44 unsigned int global_palette[16];
27 unsigned int orig_frame_width, orig_frame_height; 45 unsigned int orig_frame_width, orig_frame_height;
28 unsigned char* packet; 46 unsigned char* packet;
29 size_t packet_reserve; /* size of the memory pointed to by packet */ 47 size_t packet_reserve; /* size of the memory pointed to by packet */
30 unsigned int packet_offset; /* end of the currently assembled fragment */ 48 unsigned int packet_offset; /* end of the currently assembled fragment */
31 unsigned int packet_size; /* size of the packet once all fragments are assembled */ 49 unsigned int packet_size; /* size of the packet once all fragments are assembled */
32 unsigned int packet_pts; /* PTS for this packet */ 50 unsigned int packet_pts; /* PTS for this packet */
33 unsigned int control_start; /* index of start of control data */
34 unsigned int palette[4]; 51 unsigned int palette[4];
35 unsigned int alpha[4]; 52 unsigned int alpha[4];
36 unsigned int cuspal[4]; 53 unsigned int cuspal[4];
37 unsigned int custom; 54 unsigned int custom;
38 unsigned int now_pts; 55 unsigned int now_pts;
39 unsigned int start_pts, end_pts; 56 unsigned int start_pts, end_pts;
40 unsigned int start_col, end_col; 57 unsigned int start_col, end_col;
41 unsigned int start_row, end_row; 58 unsigned int start_row, end_row;
42 unsigned int width, height, stride; 59 unsigned int width, height, stride;
43 unsigned int current_nibble[2]; /* next data nibble (4 bits) to be
44 processed (for RLE decoding) for
45 even and odd lines */
46 int deinterlace_oddness; /* 0 or 1, index into current_nibble */
47 size_t image_size; /* Size of the image buffer */ 60 size_t image_size; /* Size of the image buffer */
48 unsigned char *image; /* Grayscale value */ 61 unsigned char *image; /* Grayscale value */
49 unsigned char *aimage; /* Alpha value */ 62 unsigned char *aimage; /* Alpha value */
50 unsigned int scaled_frame_width, scaled_frame_height; 63 unsigned int scaled_frame_width, scaled_frame_height;
51 unsigned int scaled_start_col, scaled_start_row; 64 unsigned int scaled_start_col, scaled_start_row;
61 74
62 int use_gui; 75 int use_gui;
63 int gtkMessageBox; 76 int gtkMessageBox;
64 int verbose=1; 77 int verbose=1;
65 int vobsub_id=0; 78 int vobsub_id=0;
79 int sub_pos=0;
66 80
67 static spudec_handle_t *spudec; 81 static spudec_handle_t *spudec;
68 static FILE *fsub = NULL; 82 static FILE *fsub = NULL;
69 static unsigned int sub_idx = 0; 83 static unsigned int sub_idx = 0;
70 84
169 process_gocr_output(tmpfname, spudec->start_pts, spudec->end_pts); 183 process_gocr_output(tmpfname, spudec->start_pts, spudec->end_pts);
170 unlink(buf); 184 unlink(buf);
171 unlink(tmpfname); 185 unlink(tmpfname);
172 } 186 }
173 187
188 void
189 fast_memcpy(void *a, void *b, int s)
190 { //FIXME
191 memcpy(a, b, s);
192 }
193
174 int 194 int
175 main(int argc, char **argv) 195 main(int argc, char **argv)
176 { 196 {
177 const char *vobsubname, *subripname; 197 const char *vobsubname, *subripname;
178 void *vobsub; 198 void *vobsub;
198 } 218 }
199 219
200 vobsub = vobsub_open(vobsubname, NULL, 0, &spudec); 220 vobsub = vobsub_open(vobsubname, NULL, 0, &spudec);
201 while ((packet_len=vobsub_get_next_packet(vobsub, &packet, &pts100)) >= 0) { 221 while ((packet_len=vobsub_get_next_packet(vobsub, &packet, &pts100)) >= 0) {
202 spudec_assemble(spudec, packet, packet_len, pts100); 222 spudec_assemble(spudec, packet, packet_len, pts100);
203 spudec_heartbeat(spudec, spudec->start_pts); 223 if (spudec->queue_head) {
224 spudec_heartbeat(spudec, spudec->queue_head->start_pts);
204 if (spudec_changed(spudec)) 225 if (spudec_changed(spudec))
205 spudec_draw(spudec, draw_alpha); 226 spudec_draw(spudec, draw_alpha);
227 }
206 } 228 }
207 229
208 if (vobsub) 230 if (vobsub)
209 vobsub_close(vobsub); 231 vobsub_close(vobsub);
210 exit(EXIT_SUCCESS); 232 exit(EXIT_SUCCESS);