annotate libvo/vo_pgm.c @ 8843:c70444c5b516

I have seen problems where DVD subtitles don't display at the right time and sometimes they don't appear at all. The problem stems from the fact that subtitle command packets are being applied as soon as they are read and assembled from the input stream. Sometimes, a fully assembled subtitle packet arrives at the spudec_assemble function before the previous subtitle appears onscreen and thus the viewer only sees the second subtitle. So I created a patch that queues assembled subtitle packets and applies them at the appropriate time within the heartbeat function. The reset function clears the packet queue when seeking through the video. Tomasz Farkas <tomasz_farkas@yahoo.co.uk>
author arpi
date Wed, 08 Jan 2003 18:36:36 +0000
parents 5b39e79af5fe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * video_out_pgm.c, pgm interface
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 * Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 * Hacked into mpeg2dec by
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 * Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <string.h>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
19 #include <errno.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7124
diff changeset
25 static vo_info_t info =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 "PGM file",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "pgm",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 "walken",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7124
diff changeset
33 LIBVO_EXTERN (pgm)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7124
diff changeset
34
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static int image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 static int image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 static char header[1024];
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
38 static int framenum = 0;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
39
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
40 static uint8_t *image=NULL;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
41
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
42 char vo_pgm_filename[24];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 static uint32_t
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 4737
diff changeset
45 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 image_width = width;
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
49 image=malloc(width*height*3/2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
1094
7a6be90408ea possible buffer overflows fixed
al3x
parents: 491
diff changeset
51 snprintf (header, 1024, "P5\n\n%d %d\n255\n", width, height*3/2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55
1502
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
56 static void draw_osd(void)
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
57 {
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
58 }
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 1109
diff changeset
59
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 static void flip_page (void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 FILE * f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63
1094
7a6be90408ea possible buffer overflows fixed
al3x
parents: 491
diff changeset
64 snprintf (vo_pgm_filename, 24, "%08d.pgm", framenum++);
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
65
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
66 f = fopen (vo_pgm_filename, "wb"); if (f == NULL) return;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 fwrite (header, strlen (header), 1, f);
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
68 fwrite (image, image_width, image_height*3/2, f);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 fclose (f);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
71 return;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
72 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
73
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
74 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
75 {
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
76 int i;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
77 // copy Y:
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
78 uint8_t *dst=image+image_width*y+x;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
79 uint8_t *src=srcimg[0];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
80 for(i=0;i<h;i++){
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
81 memcpy(dst,src,w);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
82 src+=stride[0];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
83 dst+=image_width;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
84 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
85 {
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
86 // copy U+V:
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
87 uint8_t *src1=srcimg[1];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
88 uint8_t *src2=srcimg[2];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
89 uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
90 for(i=0;i<h/2;i++){
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
91 memcpy(dst,src1,w/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
92 memcpy(dst+image_width/2,src2,w/2);
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
93 src1+=stride[1];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
94 src2+=stride[2];
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
95 dst+=image_width;
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
96 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
97
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
98 }
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
99
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
103
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 static uint32_t draw_frame(uint8_t * src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
106 return 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
112 if(format==IMGFMT_YV12) return 1;
15
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
113 // switch(format){
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
114 // case IMGFMT_YV12:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 // case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 // case IMGFMT_BGR|24:
15
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
117 // return 1;
2184c8945d42 query libvo for YV12 too
arpi_esp
parents: 1
diff changeset
118 // }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
491
2313c6ea006f YV12 is working again
arpi_esp
parents: 31
diff changeset
125 if(image){ free(image);image=NULL;}
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
129 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
130 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
131 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
133 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
134 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
135 if(arg)
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
136 {
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
137 printf("vo_pgm: Unknown subdevice: %s\n",arg);
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
138 return ENOSYS;
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
139 }
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
140 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
141 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 15
diff changeset
142
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
143 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
144 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
145 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
146 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
147 return query_format(*((uint32_t*)data));
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
148 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
149 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
150 }