annotate libvo/vo_gif89a.c @ 35566:5053be8dbab2

Cosmetic: Adjust indent.
author ib
date Mon, 10 Dec 2012 18:15:57 +0000
parents ddb45e9443ec
children 1a889d9a4540
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /*
27582
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
2 * MPlayer video driver for animated GIF output
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
3 *
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
4 * copyright (C) 2002 Joey Parrish <joey@nicewarrior.org>
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
5 * based on vo_directfb2.c
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
6 *
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
7 * This file is part of MPlayer.
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
8 *
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
9 * MPlayer is free software; you can redistribute it and/or
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
10 * modify it under the terms of the GNU Lesser General Public
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
11 * License as published by the Free Software Foundation; either
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
12 * version 2.1 of the License, or (at your option) any later version.
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
13 *
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
17 * Lesser General Public License for more details.
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
18 *
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
19 * You should have received a copy of the GNU Lesser General Public License
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
20 * along with MPlayer; if not, write to the Free Software Foundation, Inc.,
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34d3e0c8487a Upgrade license of LGPL 2 or later files to LGPL 2.1 or later.
diego
parents: 27385
diff changeset
22 */
8514
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 /* Notes:
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
25 * 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
26 * to achieve the desired rate. no frames will be duplicated.
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
27 *
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
28 * 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
29 * 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
30 *
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
31 * 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
32 * delay per frame to achieve the desired output framerate.
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
33 *
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
34 * 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
35 * what the gif spec uses for it's delay values.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
36 *
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
37 * 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
38 * 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
39 * 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
40 * 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
41 * (none) -- defaults to 5 fps, output file out.gif
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
42 *
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
43 * 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
44 * entire argument being interpretted as the filename.
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
45 */
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
46
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
47 #include <gif_lib.h>
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
48
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
49 #include <stdio.h>
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
50 #include <stdlib.h>
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
51 #include <string.h>
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
52 #include <unistd.h>
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
53
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
54 #include "config.h"
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
55 #include "subopt-helper.h"
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
56 #include "video_out.h"
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
57 #include "video_out_internal.h"
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
58 #include "mp_msg.h"
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
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
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
61 #define VO_GIF_REVISION 6
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
62
25216
3aee342be929 Make vo info structs const
reimar
parents: 19614
diff changeset
63 static const vo_info_t info = {
8514
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
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
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
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
67 ""
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
68 };
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
69
25220
c9e9ac2008c2 Mark the vo_functions_t definitions as const where possible.
reimar
parents: 25216
diff changeset
70 const LIBVO_EXTERN(gif89a)
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 8123
diff changeset
71
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
72
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
73 // 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
74 static float target_fps;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
75 // 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
76 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
77 // 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
78 static float ideal_delay;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
79 // 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
80 static float ideal_time;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
81 // actual time thus far.
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
82 static int real_time;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
83 // 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
84 static float frame_cycle;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
85 // 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
86 static int cycle_pos;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
87 // 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
88 static float frame_adj;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
89
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
90 // 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
91 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
92 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
93 // image data for slice rendering
8665
8b572238f63e sig11 (in free() in uninit) fixed
arpi
parents: 8514
diff changeset
94 static uint8_t *slice_data = NULL;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
95 // 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
96 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
97 // 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
98 static ColorMapObject *reduce_cmap = NULL;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
99
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
100 // 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
101 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
102 // 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
103 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
104 // the default output filename
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
105 #define DEFAULT_FILE "out.gif"
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
106
28828
56eee6ffba9b Make data related to suboption parsing const in libvo
reimar
parents: 28232
diff changeset
107 static const opt_t subopts[] = {
28922
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
108 {"output", OPT_ARG_MSTRZ, &gif_filename, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
109 {"fps", OPT_ARG_FLOAT, &target_fps, NULL},
9dd905e52639 Remove obsolete extra elements from opt_t struct initialization.
diego
parents: 28828
diff changeset
110 {NULL, 0, NULL, NULL}
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
111 };
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
112
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
113 static int preinit(const char *arg)
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
114 {
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
115 target_fps = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
116
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
117 if (subopt_parse(arg, subopts) != 0) {
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
118 mp_msg(MSGT_VO, MSGL_FATAL,
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
119 "\n-vo gif89a command line help:\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
120 "Example: mplayer -vo gif89a:output=file.gif:fps=4.9\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
121 "\nOptions:\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
122 " output=<filename>\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
123 " Specify the output file. The default is out.gif.\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
124 " fps=<rate>\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
125 " Specify the target framerate. The default is 5.0.\n"
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
126 "\n");
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
127 return -1;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
128 }
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
129
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
130 if (target_fps > vo_fps)
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
131 target_fps = vo_fps; // i will not duplicate frames.
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
132
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
133 if (target_fps <= 0) {
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
134 target_fps = default_fps;
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
135 mp_msg(MSGT_VO, MSGL_V, "GIF89a: default, %.2f fps\n", target_fps);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
136 } else {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
137 mp_msg(MSGT_VO, MSGL_V, "GIF89a: output fps forced to %.2f\n", target_fps);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
138 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
139
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
140 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
141 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
142 // we make one output frame every (frame_cycle) frames, on average.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
143
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
144 if (gif_filename == NULL) {
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
145 gif_filename = strdup(DEFAULT_FILE);
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
146 mp_msg(MSGT_VO, MSGL_V, "GIF89a: default, file \"%s\"\n", gif_filename);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
147 } else {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
148 mp_msg(MSGT_VO, MSGL_V, "GIF89a: file forced to \"%s\"\n", gif_filename);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
149 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
150
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
151 mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: Preinit OK\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
152 return 0;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
153 }
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
154
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
155 static int config(uint32_t s_width, uint32_t s_height, uint32_t d_width,
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 11865
diff changeset
156 uint32_t d_height, uint32_t flags, char *title,
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
157 uint32_t format)
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
158 {
27385
2113bd9c6bd9 Rename preprocessor directives related to image libraries.
diego
parents: 25220
diff changeset
159 #ifdef CONFIG_GIF_4
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
160 // 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
161 char LB1[] = "NETSCAPE2.0";
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
162 char LB2[] = { 1, 0, 0 };
6078
4a9c7041141d cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
arpi
parents: 6053
diff changeset
163 #endif
4a9c7041141d cleanups, removed swscaler, osd support - by Joey Parrish <joey@yunamusic.com>
arpi
parents: 6053
diff changeset
164
17366
934380353fd6 massive attack: mp_msg printf format fixes
rathann
parents: 16721
diff changeset
165 mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: Config entered [%dx%d]\n", s_width,s_height);
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
166 mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: With requested format: %s\n", vo_format_name(format));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
167
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
168 // save these for later.
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
169 img_width = s_width;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
170 img_height = s_height;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
171
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
172 // 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
173 // 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
174 if (vo_config_count > 0) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
175 mp_msg(MSGT_VO, MSGL_V, "GIF89a: Reconfigure attempted.\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
176 return 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
177 }
8665
8b572238f63e sig11 (in free() in uninit) fixed
arpi
parents: 8514
diff changeset
178 // 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
179 // 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
180 // 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
181 // gif will have the dimensions of the first movie.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
182
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
183 if (format != IMGFMT_RGB24) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
184 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Error - given unsupported colorspace.\n");
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
185 return 1;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
186 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
187
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
188 // 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
189 // 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
190 // 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
191 // you need to upgrade your gif library.
27385
2113bd9c6bd9 Rename preprocessor directives related to image libraries.
diego
parents: 25220
diff changeset
192 #ifdef CONFIG_GIF_4
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
193 EGifSetGifVersion("89a");
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
194 #else
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
195 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Your version of libungif needs to be upgraded.\n");
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
196 mp_msg(MSGT_VO, MSGL_ERR, "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
197 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
198
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
199 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
200 if (new_gif == NULL) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
201 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: error opening file \"%s\" for output.\n", gif_filename);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
202 return 1;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
203 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
204
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
205 slice_data = malloc(img_width * img_height * 3);
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
206 if (slice_data == NULL) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
207 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: malloc failed.\n");
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
208 return 1;
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
209 }
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
210
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
211 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
212 if (reduce_data == NULL) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
213 free(slice_data); slice_data = NULL;
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
214 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: malloc failed.\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
215 return 1;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
216 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
217
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
218 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
219 if (reduce_cmap == NULL) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
220 free(slice_data); slice_data = NULL;
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
221 free(reduce_data); reduce_data = NULL;
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
222 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: malloc failed.\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
223 return 1;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
224 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
225
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
226 // 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
227 ideal_time = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
228 real_time = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
229 cycle_pos = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
230 frame_adj = 0;
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 // 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
233 EGifPutScreenDesc(new_gif, s_width, s_height, 256, 0, reduce_cmap);
27385
2113bd9c6bd9 Rename preprocessor directives related to image libraries.
diego
parents: 25220
diff changeset
234 #ifdef CONFIG_GIF_4
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
235 // 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
236 // 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
237 // 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
238 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
239 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
240 #endif
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
241
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
242 mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: Config finished.\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
243 return 0;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
244 }
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
245
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
246 // we do not draw osd.
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 27582
diff changeset
247 void draw_osd(void) {}
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
248
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
249 // 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
250 static void check_events(void) {}
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
251
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
252 static int gif_reduce(int width, int height, uint8_t *src, uint8_t *dst, GifColorType *colors)
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
253 {
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
254 unsigned char Ra[width * height];
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
255 unsigned char Ga[width * height];
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
256 unsigned char Ba[width * height];
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
257 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
258 int size = 256;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
259 int i;
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
260
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
261 R = Ra; G = Ga; B = Ba;
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
262 for (i = 0; i < width * height; i++)
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
263 {
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
264 *R++ = *src++;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
265 *G++ = *src++;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
266 *B++ = *src++;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
267 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
268
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
269 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
270 return QuantizeBuffer(width, height, &size, R, G, B, dst, colors);
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
271 }
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
272
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
273 static void flip_page(void)
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
274 {
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
275 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
276 int delay = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
277 int ret;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
278
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
279 cycle_pos++;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
280 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
281 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
282
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
283 // quantize the image
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
284 ret = gif_reduce(img_width, img_height, slice_data, reduce_data, reduce_cmap->Colors);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
285 if (ret == GIF_ERROR) {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
286 mp_msg(MSGT_VO, MSGL_ERR, "GIF89a: Quantize failed.\n");
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
287 return;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
288 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
289
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
290 // 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
291 ideal_time += ideal_delay;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
292 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
293 real_time += delay;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
294 frame_adj += cycle_pos;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
295 frame_adj -= frame_cycle;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
296 cycle_pos = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
297
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
298 // 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
299 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
300 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
301 CB[2] = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
302 CB[3] = 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
303
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
304 // 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
305 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
306 // put the image description
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
307 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
308 // put the image itself
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
309 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
310 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
311
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
312 static int draw_frame(uint8_t *src[])
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
313 {
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
314 return 1;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
315 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
316
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
317 static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
318 {
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
319 uint8_t *dst, *frm;
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
320 int i;
8665
8b572238f63e sig11 (in free() in uninit) fixed
arpi
parents: 8514
diff changeset
321 dst = slice_data + (img_width * y + x) * 3;
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
322 frm = src[0];
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
323 for (i = 0; i < h; i++) {
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
324 memcpy(dst, frm, w * 3);
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
325 dst += (img_width * 3);
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
326 frm += stride[0];
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
327 }
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
328 return 0;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
329 }
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
330
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
331 static int query_format(uint32_t format)
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
332 {
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
333 if (format == IMGFMT_RGB24)
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
334 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_TIMER | VFCAP_ACCEPT_STRIDE;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
335 return 0;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
336 }
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
337
33305
ddb45e9443ec Remove the variable arguments from the libvo control() functions.
iive
parents: 32537
diff changeset
338 static int control(uint32_t request, void *data)
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
339 {
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
340 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
341 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
342 }
9540
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
343 if (request == VOCTRL_DUPLICATE_FRAME) {
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
344 flip_page();
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
345 return VO_TRUE;
ea4ca6a17d96 remove yuv2rgb and support frame duplication
joey
parents: 8665
diff changeset
346 }
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
347 return VO_NOTIMPL;
6053
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
348 }
759c5a3314a2 -vo gif - by Joey Parrish <joey@yunamusic.com>
arpi
parents:
diff changeset
349
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
350 static void uninit(void)
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
351 {
16721
bd815e9973f2 use subopt parser for arguments.
joey
parents: 16280
diff changeset
352 mp_msg(MSGT_VO, MSGL_DBG2, "GIF89a: Uninit entered\n");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
353
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
354 if (new_gif != NULL) {
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
355 char temp[256];
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
356 // 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
357 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
358 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
359 "joey@nicewarrior.org");
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
360 EGifPutComment(new_gif, temp);
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
361 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
362 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
363
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
364 // free our allocated ram
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30633
diff changeset
365 free(gif_filename);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30633
diff changeset
366 free(slice_data);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 30633
diff changeset
367 free(reduce_data);
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
368 if (reduce_cmap != NULL) FreeMapObject(reduce_cmap);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28922
diff changeset
369
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
370 // 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
371 new_gif = NULL;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
372 gif_filename = NULL;
8665
8b572238f63e sig11 (in free() in uninit) fixed
arpi
parents: 8514
diff changeset
373 slice_data = NULL;
8514
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
374 reduce_data = NULL;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
375 reduce_cmap = NULL;
a1ff87c254ff I have rewritten the gif89a vo in order to solve some problems I had
arpi
parents: 8148
diff changeset
376 }