Mercurial > mplayer.hg
comparison libvo/vo_gif89a.c @ 6078:4a9c7041141d
cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
author | arpi |
---|---|
date | Mon, 13 May 2002 20:47:03 +0000 |
parents | 759c5a3314a2 |
children | a59795bd14d0 |
comparison
equal
deleted
inserted
replaced
6077:754c2af16815 | 6078:4a9c7041141d |
---|---|
37 | 37 |
38 static int image_width; | 38 static int image_width; |
39 static int image_height; | 39 static int image_height; |
40 static int image_format; | 40 static int image_format; |
41 static uint8_t *image_data=NULL; | 41 static uint8_t *image_data=NULL; |
42 static unsigned int scale_srcW = 0, scale_srcH = 0; | |
43 | 42 |
44 static int reverse_map = 0; | 43 static int reverse_map = 0; |
45 static unsigned char framenum = 0; | 44 static unsigned char framenum = 0; |
46 static int gif_frameskip; | 45 static int gif_frameskip; |
47 static int gif_framedelay; | 46 static int gif_framedelay; |
48 static int target_fps = 0; | 47 static int target_fps = 0; |
49 | 48 |
50 GifFileType *newgif=NULL; | 49 GifFileType *newgif=NULL; |
51 | 50 |
52 /* | |
53 * TODO | |
54 * OSD!!! | |
55 */ | |
56 | |
57 static uint32_t config | 51 static uint32_t config |
58 (uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, | 52 (uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, |
59 uint32_t fullscreen, char *title, uint32_t format, const vo_tune_info_t *info) { | 53 uint32_t fullscreen, char *title, uint32_t format, const vo_tune_info_t *info) { |
60 char filename[] = "out.gif"; | 54 char filename[] = "out.gif"; |
61 ColorMapObject *Cmap; | 55 ColorMapObject *Cmap; |
56 #ifdef HAVE_GIF_4 | |
62 char LB[] = { | 57 char LB[] = { |
63 'N','E','T','S', | 58 'N','E','T','S', |
64 'C','A','P','E', | 59 'C','A','P','E', |
65 '2','.','0' }; | 60 '2','.','0' }; |
66 char LB2[] = { 1, 0x00, 0x00 }; | 61 char LB2[] = { 1, 0x00, 0x00 }; |
62 #endif | |
67 | 63 |
68 if (target_fps == 0) target_fps = 5; | 64 if (target_fps == 0) target_fps = 5; |
69 gif_frameskip = (vo_fps + 0.25) / target_fps; | 65 gif_frameskip = (vo_fps + 0.25) / target_fps; |
70 gif_framedelay = 100 / target_fps; | 66 gif_framedelay = 100 / target_fps; |
71 | 67 |
72 if ((width != d_width) || (height != d_height)) { | 68 image_width = width; |
73 image_width = (d_width + 7) & ~7; | 69 image_height = height; |
74 image_height = d_height; | |
75 scale_srcW = width; | |
76 scale_srcH = height; | |
77 SwScale_Init(); | |
78 } else { | |
79 image_width = width; | |
80 image_height = height; | |
81 } | |
82 image_format = format; | 70 image_format = format; |
83 | 71 |
84 Cmap = MakeMapObject(256, NULL); | 72 Cmap = MakeMapObject(256, NULL); |
85 | 73 |
86 switch(format) { | 74 switch(format) { |
87 case IMGFMT_BGR32: | |
88 case IMGFMT_BGR24: | 75 case IMGFMT_BGR24: |
89 reverse_map = 1; | 76 reverse_map = 1; |
90 break; | 77 break; |
91 case IMGFMT_RGB32: | |
92 case IMGFMT_RGB24: | 78 case IMGFMT_RGB24: |
93 break; | 79 break; |
94 case IMGFMT_IYUV: | |
95 case IMGFMT_I420: | |
96 case IMGFMT_YV12: | 80 case IMGFMT_YV12: |
97 reverse_map = 1; | |
98 yuv2rgb_init(24, MODE_RGB); | 81 yuv2rgb_init(24, MODE_RGB); |
99 image_data = malloc(image_width*image_height*3); | 82 image_data = malloc(image_width*image_height*3); |
100 break; | 83 break; |
101 default: | 84 default: |
102 return 1; | 85 return 1; |
103 } | 86 } |
104 | 87 |
105 if (vo_config_count > 0) | 88 if (vo_config_count > 0) |
106 return 0; | 89 return 0; |
107 | 90 |
91 // this line causes crashes in certain earlier versions of libungif. | |
92 // i don't know exactly which, but certainly all those before v4. | |
93 // if you have problems, you need to upgrade your gif library. | |
94 #ifdef HAVE_GIF_4 | |
108 EGifSetGifVersion("89a"); | 95 EGifSetGifVersion("89a"); |
96 #else | |
97 fprintf(stderr, "vo_gif89a: Your version of libgif/libungif needs to be upgraded.\n"); | |
98 fprintf(stderr, "vo_gif89a: Some functionality has been disabled.\n"); | |
99 #endif | |
109 newgif = EGifOpenFileName(filename, 0); | 100 newgif = EGifOpenFileName(filename, 0); |
110 if (newgif == NULL) | 101 if (newgif == NULL) |
111 { | 102 { |
112 fprintf(stderr, "error opening file for output.\n"); | 103 fprintf(stderr, "error opening file for output.\n"); |
113 return(1); | 104 return(1); |
114 } | 105 } |
115 EGifPutScreenDesc(newgif, image_width, image_height, 256, 0, Cmap); | 106 EGifPutScreenDesc(newgif, image_width, image_height, 256, 0, Cmap); |
107 #ifdef HAVE_GIF_4 | |
108 // version 3 of libgif/libungif does not support multiple control blocks. | |
109 // for this version, looping will be disabled. | |
116 EGifPutExtensionFirst(newgif, 0xFF, 11, LB); | 110 EGifPutExtensionFirst(newgif, 0xFF, 11, LB); |
117 EGifPutExtensionLast(newgif, 0, 3, LB2); | 111 EGifPutExtensionLast(newgif, 0, 3, LB2); |
112 #endif | |
118 | 113 |
119 return 0; | 114 return 0; |
120 } | 115 } |
121 | 116 |
122 static const vo_info_t* get_info(void) | 117 static const vo_info_t* get_info(void) |
132 int z; | 127 int z; |
133 char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0}; | 128 char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0}; |
134 | 129 |
135 if ((framenum++ % gif_frameskip)) return(0); | 130 if ((framenum++ % gif_frameskip)) return(0); |
136 | 131 |
137 if ((image_format == IMGFMT_BGR32) || (image_format == IMGFMT_RGB32)) | |
138 { | |
139 rgb32to24(src[0], image_data, image_width * image_height * 4); | |
140 src[0] = image_data; | |
141 } | |
142 | |
143 Cmap = MakeMapObject(256, NULL); | 132 Cmap = MakeMapObject(256, NULL); |
144 use_data = (uint8_t *)malloc(image_width * image_height); | 133 use_data = (uint8_t *)malloc(image_width * image_height); |
145 if (gif_reduce(image_width, image_height, src[0], use_data, Colors)) return(0); | 134 if (gif_reduce(image_width, image_height, src[0], use_data, Colors)) return(0); |
146 | 135 |
147 if (reverse_map) | 136 if (reverse_map) |
168 free(use_data); | 157 free(use_data); |
169 | 158 |
170 return (0); | 159 return (0); |
171 } | 160 } |
172 | 161 |
162 #ifdef USE_OSD | |
163 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) | |
164 { | |
165 vo_draw_alpha_rgb24(w, h, src, srca, stride, image_data + 3 * (y0 * image_width + x0), 3 * image_width); | |
166 } | |
167 #endif | |
168 | |
173 static void draw_osd(void) | 169 static void draw_osd(void) |
174 { | 170 { |
171 #ifdef USE_OSD | |
172 vo_draw_text(image_width, image_height, draw_alpha); | |
173 #endif | |
175 } | 174 } |
176 | 175 |
177 static void flip_page (void) | 176 static void flip_page (void) |
178 { | 177 { |
179 uint8_t *use_data; | 178 uint8_t *use_data; |
180 ColorMapObject *Cmap; | 179 ColorMapObject *Cmap; |
181 uint8_t Colors[256 * 3]; | 180 uint8_t Colors[256 * 3]; |
182 int z; | 181 int z; |
183 char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0}; | 182 char CB[] = { (char)(gif_framedelay >> 8), (char)(gif_framedelay & 0xff), 0, 0}; |
184 | 183 |
185 if ((image_format == IMGFMT_YV12) || (image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420)) { | 184 if (image_format == IMGFMT_YV12) { |
186 | 185 |
187 if ((framenum++ % gif_frameskip)) return; | 186 if ((framenum++ % gif_frameskip)) return; |
188 | 187 |
189 Cmap = MakeMapObject(256, NULL); | 188 Cmap = MakeMapObject(256, NULL); |
190 use_data = (uint8_t *)malloc(image_width * image_height); | 189 use_data = (uint8_t *)malloc(image_width * image_height); |
215 } | 214 } |
216 } | 215 } |
217 | 216 |
218 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) | 217 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y ) |
219 { | 218 { |
220 /* hack: swap planes for I420 ;) -- alex */ | 219 uint8_t *dst = image_data + (image_width * y + x) * 3; |
221 if ((image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420)) | 220 yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*3,stride[0],stride[1]); |
222 { | |
223 uint8_t *src_i420[3]; | |
224 | |
225 src_i420[0] = src[0]; | |
226 src_i420[1] = src[2]; | |
227 src_i420[2] = src[1]; | |
228 src = src_i420; | |
229 } | |
230 | |
231 if (scale_srcW) { | |
232 uint8_t *dst[3] = {image_data, NULL, NULL}; | |
233 SwScale_YV12slice(src,stride,y,h, | |
234 dst, image_width*3, 24, | |
235 scale_srcW, scale_srcH, image_width, image_height); | |
236 } else { | |
237 uint8_t *dst = image_data + (image_width * y + x) * 3; | |
238 yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*3,stride[0],stride[1]); | |
239 } | |
240 return 0; | 221 return 0; |
241 } | 222 } |
242 | 223 |
243 static uint32_t | 224 static uint32_t |
244 query_format(uint32_t format) | 225 query_format(uint32_t format) |
245 { | 226 { |
246 switch(format){ | 227 switch(format){ |
247 case IMGFMT_IYUV: | |
248 case IMGFMT_I420: | |
249 case IMGFMT_YV12: | 228 case IMGFMT_YV12: |
250 case IMGFMT_RGB|32: | |
251 case IMGFMT_BGR|32: | |
252 case IMGFMT_RGB|24: | 229 case IMGFMT_RGB|24: |
253 case IMGFMT_BGR|24: | 230 case IMGFMT_BGR|24: |
254 return 1 | VFCAP_SWSCALE | VFCAP_TIMER | VFCAP_ACCEPT_STRIDE; | 231 return 1 | VFCAP_TIMER | VFCAP_ACCEPT_STRIDE; |
255 } | 232 } |
256 return 0; | 233 return 0; |
257 } | 234 } |
258 | 235 |
259 static void | 236 static void |