Mercurial > mplayer.hg
annotate libvo/vo_gif89a.c @ 8952:2369087bb777
Fix for endianess conversion if input to libaf is float
author | anders |
---|---|
date | Tue, 14 Jan 2003 02:52:10 +0000 |
parents | 8b572238f63e |
children | ea4ca6a17d96 |
rev | line source |
---|---|
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
1 /* |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
2 MPlayer video driver for animated gif output |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
3 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
4 (C) 2002 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
5 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
6 Written by Joey Parrish <joey@nicewarrior.org> |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
7 Based on vo_directfb2.c |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
8 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
9 This library is free software; you can redistribute it and/or |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
10 modify it under the terms of the GNU Lesser General Public |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
11 License as published by the Free Software Foundation; either |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
12 version 2 of the License, or (at your option) any later version. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
13 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
14 This library is distributed in the hope that it will be useful, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
17 Lesser General Public License for more details. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
18 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
19 You should have received a copy of the GNU Lesser General Public |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
20 License along with this library; if not, write to the |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
21 Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
22 Boston, MA 02111-1307, USA. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
23 */ |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
24 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
25 /* Notes: |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
26 * when setting output framerate, frames will be ignored as needed |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
27 * to achieve the desired rate. no frames will be duplicated. |
6053 | 28 * |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
29 * output framerate can be specified as a float |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
30 * value now, instead of just an int. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
31 * |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
32 * adjustments will be made to both the frame drop cycle and the |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
33 * delay per frame to achieve the desired output framerate. |
6053 | 34 * |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
35 * time values are in centiseconds, because that's |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
36 * what the gif spec uses for it's delay values. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
37 * |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
38 * preinit looks for arguments in one of the following formats (in this order): |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
39 * fps:filename -- sets the framerate (float) and output file |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
40 * fps -- sets the framerate (float), default file out.gif |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
41 * filename -- defaults to 5 fps, sets output file |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
42 * (none) -- defaults to 5 fps, output file out.gif |
6053 | 43 * |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
44 * trying to put the filename before the framerate will result in the |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
45 * entire argument being interpretted as the filename. |
6053 | 46 */ |
47 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
48 #include <gif_lib.h> |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
49 |
6053 | 50 #include <stdio.h> |
51 #include <stdlib.h> | |
52 #include <string.h> | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
53 #include <unistd.h> |
6053 | 54 |
55 #include "config.h" | |
56 #include "video_out.h" | |
57 #include "video_out_internal.h" | |
58 #include "../postproc/rgb2rgb.h" | |
59 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
60 #define MPLAYER_VERSION 0.90 |
8665 | 61 #define VO_GIF_REVISION 4 |
6053 | 62 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
63 static vo_info_t info = { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
64 "animated GIF output", |
6053 | 65 "gif89a", |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
66 "Joey Parrish joey@nicewarrior.org", |
6053 | 67 "" |
68 }; | |
69 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
70 LIBVO_EXTERN(gif89a) |
8148
5b39e79af5fe
removed get_info, using the same sheme as in libmpcodecs instead
alex
parents:
8123
diff
changeset
|
71 |
6053 | 72 extern int verbose; |
73 extern int vo_config_count; | |
74 | |
75 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
76 // how many frames per second we are aiming for during output. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
77 static float target_fps; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
78 // default value for output fps. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
79 static const float default_fps = 5.00; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
80 // the ideal gif delay per frame. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
81 static float ideal_delay; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
82 // the ideal time thus far. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
83 static float ideal_time; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
84 // actual time thus far. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
85 static int real_time; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
86 // nominal framedrop cycle length in frames |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
87 static float frame_cycle; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
88 // position in the framedrop cycle |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
89 static int cycle_pos; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
90 // adjustment of the framedrop cycle |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
91 static float frame_adj; |
6053 | 92 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
93 // the output width and height |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
94 static uint32_t img_width; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
95 static uint32_t img_height; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
96 // image data for slice rendering |
8665 | 97 static uint8_t *slice_data = NULL; |
98 // pointer for whole frame rendering | |
99 static uint8_t *frame_data = NULL; | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
100 // reduced image data for flip_page |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
101 static uint8_t *reduce_data = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
102 // reduced color map for flip_page |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
103 static ColorMapObject *reduce_cmap = NULL; |
6053 | 104 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
105 // a pointer to the gif structure |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
106 static GifFileType *new_gif = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
107 // a string to contain the filename of the output gif |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
108 static char *gif_filename = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
109 // the default output filename |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
110 #define DEFAULT_FILE "out.gif" |
6053 | 111 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
112 static uint32_t preinit(const char *arg) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
113 { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
114 float fps; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
115 if (verbose) printf("GIF89a: Preinit entered\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
116 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
117 target_fps = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
118 fps = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
119 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
120 if (arg) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
121 char *temp = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
122 if (sscanf(arg, "%f", &fps)) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
123 if (fps < 0) fps = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
124 // find the next argument |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
125 temp = strchr(arg, ':'); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
126 if (temp != NULL) temp++; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
127 } else { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
128 // find the first argument |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
129 temp = (char *)arg; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
130 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
131 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
132 if (temp != NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
133 if (*temp != '\0') { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
134 gif_filename = strdup(temp); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
135 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
136 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
137 } |
6053 | 138 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
139 if (fps > vo_fps) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
140 fps = vo_fps; // i will not duplicate frames. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
141 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
142 if (fps <= 0) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
143 target_fps = default_fps; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
144 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
145 printf("GIF89a: default, %.2f fps\n", target_fps); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
146 } else { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
147 target_fps = fps; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
148 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
149 printf("GIF89a: output fps forced to %.2f\n", target_fps); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
150 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
151 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
152 ideal_delay = 100 / target_fps; // in centiseconds |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
153 frame_cycle = vo_fps / target_fps; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
154 // we make one output frame every (frame_cycle) frames, on average. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
155 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
156 if (gif_filename == NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
157 gif_filename = strdup(DEFAULT_FILE); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
158 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
159 printf("GIF89a: default, file \"%s\"\n", gif_filename); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
160 } else { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
161 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
162 printf("GIF89a: file forced to \"%s\"\n", gif_filename); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
163 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
164 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
165 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
166 printf("GIF89a: Preinit OK\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
167 return 0; |
6053 | 168 } |
169 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
170 static uint32_t config(uint32_t s_width, uint32_t s_height, uint32_t d_width, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
171 uint32_t d_height, uint32_t fullscreen, char *title, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
172 uint32_t format) |
6053 | 173 { |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
174 #ifdef HAVE_GIF_4 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
175 // these are control blocks for the gif looping extension. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
176 char LB1[] = "NETSCAPE2.0"; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
177 char LB2[] = { 1, 0, 0 }; |
6078
4a9c7041141d
cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6053
diff
changeset
|
178 #endif |
4a9c7041141d
cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6053
diff
changeset
|
179 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
180 if (verbose) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
181 printf("GIF89a: Config entered [%ix%i]\n",s_width,s_height); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
182 printf("GIF89a: With requested format: %s\n",vo_format_name(format)); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
183 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
184 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
185 // save these for later. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
186 img_width = s_width; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
187 img_height = s_height; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
188 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
189 // multiple configs without uninit are not allowed. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
190 // this is because config opens a new gif file. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
191 if (vo_config_count > 0) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
192 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
193 printf("GIF89a: Reconfigure attempted.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
194 return 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
195 } |
8665 | 196 // reconfigure need not be a fatal error, so return 0. |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
197 // multiple configs without uninit will result in two |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
198 // movies concatenated in one gif file. the output |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
199 // gif will have the dimensions of the first movie. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
200 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
201 switch (format) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
202 case IMGFMT_RGB24: break; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
203 case IMGFMT_YV12: |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
204 yuv2rgb_init(24, MODE_BGR); |
8665 | 205 slice_data = malloc(img_width * img_height * 3); |
206 if (slice_data == NULL) { | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
207 printf("GIF89a: malloc failed.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
208 return 1; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
209 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
210 break; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
211 default: |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
212 printf("GIF89a: Error - given unsupported colorspace.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
213 return 1; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
214 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
215 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
216 // the EGifSetGifVersion line causes segfaults in certain |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
217 // earlier versions of libungif. i don't know exactly which, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
218 // but certainly in all those before v4. if you have problems, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
219 // you need to upgrade your gif library. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
220 #ifdef HAVE_GIF_4 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
221 EGifSetGifVersion("89a"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
222 #else |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
223 printf("GIF89a: Your version of libungif needs to be upgraded.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
224 printf("GIF89a: Some functionality has been disabled.\n"); |
6078
4a9c7041141d
cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
6053
diff
changeset
|
225 #endif |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
226 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
227 new_gif = EGifOpenFileName(gif_filename, 0); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
228 if (new_gif == NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
229 printf("GIF89a: error opening file \"%s\" for output.\n", gif_filename); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
230 return 1; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
231 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
232 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
233 reduce_data = malloc(img_width * img_height); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
234 if (reduce_data == NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
235 printf("GIF89a: malloc failed.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
236 return 1; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
237 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
238 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
239 reduce_cmap = MakeMapObject(256, NULL); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
240 if (reduce_cmap == NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
241 printf("GIF89a: malloc failed.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
242 return 1; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
243 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
244 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
245 // initialize the delay and framedrop variables. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
246 ideal_time = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
247 real_time = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
248 cycle_pos = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
249 frame_adj = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
250 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
251 // set the initial width and height info. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
252 EGifPutScreenDesc(new_gif, s_width, s_height, 256, 0, reduce_cmap); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
253 #ifdef HAVE_GIF_4 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
254 // version 3 of libungif does not support multiple control blocks. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
255 // looping requires multiple control blocks. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
256 // therefore, looping is only enabled for v4 and up. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
257 EGifPutExtensionFirst(new_gif, 0xFF, 11, LB1); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
258 EGifPutExtensionLast(new_gif, 0, 3, LB2); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
259 #endif |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
260 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
261 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
262 printf("GIF89a: Config finished.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
263 return 0; |
6053 | 264 } |
265 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
266 // we do not draw osd. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
267 void draw_osd() {} |
6053 | 268 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
269 // we do not handle events. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
270 static void check_events(void) {} |
6053 | 271 |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
272 static int gif_reduce(int width, int height, uint8_t *src, uint8_t *dst, GifColorType *colors) |
6053 | 273 { |
274 unsigned char Ra[width * height]; | |
275 unsigned char Ga[width * height]; | |
276 unsigned char Ba[width * height]; | |
277 unsigned char *R, *G, *B; | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
278 int size = 256; |
6053 | 279 int i; |
280 | |
281 R = Ra; G = Ga; B = Ba; | |
282 for (i = 0; i < width * height; i++) | |
283 { | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
284 *R++ = *src++; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
285 *G++ = *src++; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
286 *B++ = *src++; |
6053 | 287 } |
288 | |
289 R = Ra; G = Ga; B = Ba; | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
290 return QuantizeBuffer(width, height, &size, R, G, B, dst, colors); |
6053 | 291 } |
292 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
293 static void flip_page(void) |
6053 | 294 { |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
295 char CB[4]; // control block |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
296 int delay = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
297 int ret; |
8665 | 298 uint8_t *img_data; |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
299 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
300 cycle_pos++; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
301 if (cycle_pos < frame_cycle - frame_adj) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
302 return; // we are skipping this frame |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
303 |
8665 | 304 // slice_data is used for per slice rendering, |
305 // and frame_data is used for per frame rendering. | |
306 // i seperated these two because slice_data is | |
307 // ram i allocate, and frame_data is not. | |
308 // using one pointer for both can lead to | |
309 // either segfault (freeing ram that i'm not supposed | |
310 // to) or memory leaks (not freeing any ram at all) | |
311 if (slice_data != NULL) img_data = slice_data; | |
312 else img_data = frame_data; | |
313 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
314 // quantize the image |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
315 ret = gif_reduce(img_width, img_height, img_data, reduce_data, reduce_cmap->Colors); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
316 if (ret == GIF_ERROR) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
317 printf("GIF89a: Quantize failed.\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
318 return; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
319 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
320 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
321 // calculate frame delays and frame skipping |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
322 ideal_time += ideal_delay; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
323 delay = (int)(ideal_time - real_time); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
324 real_time += delay; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
325 frame_adj += cycle_pos; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
326 frame_adj -= frame_cycle; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
327 cycle_pos = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
328 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
329 // set up the delay control block |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
330 CB[0] = (char)(delay >> 8); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
331 CB[1] = (char)(delay & 0xff); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
332 CB[2] = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
333 CB[3] = 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
334 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
335 // put the control block with delay info |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
336 EGifPutExtension(new_gif, 0xF9, 0x04, CB); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
337 // put the image description |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
338 EGifPutImageDesc(new_gif, 0, 0, img_width, img_height, 0, reduce_cmap); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
339 // put the image itself |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
340 EGifPutLine(new_gif, reduce_data, img_width * img_height); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
341 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
342 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
343 static uint32_t draw_frame(uint8_t *src[]) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
344 { |
8665 | 345 frame_data = src[0]; |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
346 return 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
347 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
348 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
349 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
350 { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
351 uint8_t *dst; |
8665 | 352 dst = slice_data + (img_width * y + x) * 3; |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
353 yuv2rgb(dst, src[0], src[1], src[2], w, h, img_width * 3, stride[0], stride[1]); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
354 return 0; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
355 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
356 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
357 static uint32_t query_format(uint32_t format) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
358 { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
359 switch (format) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
360 case IMGFMT_YV12: |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
361 return VFCAP_CSP_SUPPORTED | VFCAP_TIMER | VFCAP_ACCEPT_STRIDE; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
362 case IMGFMT_RGB24: |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
363 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_TIMER; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
364 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
365 return 0; |
6053 | 366 } |
367 | |
368 static uint32_t control(uint32_t request, void *data, ...) | |
369 { | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
370 if (request == VOCTRL_QUERY_FORMAT) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
371 return query_format(*((uint32_t*)data)); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
372 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
373 return VO_NOTIMPL; |
6053 | 374 } |
375 | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
376 static void uninit(void) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
377 { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
378 if (verbose) |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
379 printf("GIF89a: Uninit entered\n"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
380 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
381 if (new_gif != NULL) { |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
382 char temp[256]; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
383 // comment the gif and close it |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
384 snprintf(temp, 256, "MPlayer gif output v%2.2f-%d (c) %s\r\n", |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
385 MPLAYER_VERSION, VO_GIF_REVISION, |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
386 "joey@nicewarrior.org"); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
387 EGifPutComment(new_gif, temp); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
388 EGifCloseFile(new_gif); // also frees gif storage space. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
389 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
390 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
391 // free our allocated ram |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
392 if (gif_filename != NULL) free(gif_filename); |
8665 | 393 if (slice_data != NULL) free(slice_data); |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
394 if (reduce_data != NULL) free(reduce_data); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
395 if (reduce_cmap != NULL) FreeMapObject(reduce_cmap); |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
396 |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
397 // set the pointers back to null. |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
398 new_gif = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
399 gif_filename = NULL; |
8665 | 400 frame_data = NULL; |
401 slice_data = NULL; | |
8514
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
402 reduce_data = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
403 reduce_cmap = NULL; |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
404 } |
a1ff87c254ff
I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents:
8148
diff
changeset
|
405 |