Browse code

lavd: drop SDL1 device and SDL1 support

Signed-off-by: Josh de Kock <josh@itanimul.li>

Josh de Kock authored on 2016/09/23 03:20:24
Showing 5 changed files
... ...
@@ -34,6 +34,7 @@ version <next>:
34 34
 - Non-Local Means (nlmeans) denoising filter
35 35
 - sdl2 output device
36 36
 - sdl2 support for ffplay
37
+- sdl1 output device and sdl1 support removed
37 38
 
38 39
 
39 40
 version 3.1:
... ...
@@ -291,7 +291,6 @@ External library support:
291 291
                            if gnutls is not used [no]
292 292
   --disable-schannel       disable SChannel SSP, needed for TLS support on
293 293
                            Windows if openssl and gnutls are not used [autodetect]
294
-  --disable-sdl            disable sdl [autodetect]
295 294
   --disable-sdl2           disable sdl2 [autodetect]
296 295
   --disable-securetransport disable Secure Transport, needed for TLS support
297 296
                            on OSX if openssl and gnutls are not used [autodetect]
... ...
@@ -1548,7 +1547,6 @@ EXTERNAL_LIBRARY_LIST="
1548 1548
     opengl
1549 1549
     openssl
1550 1550
     schannel
1551
-    sdl
1552 1551
     sdl2
1553 1552
     securetransport
1554 1553
     videotoolbox
... ...
@@ -2023,7 +2021,6 @@ HAVE_LIST="
2023 2023
     MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS
2024 2024
     perl
2025 2025
     pod2man
2026
-    sdl
2027 2026
     sdl2
2028 2027
     section_data_rel_ro
2029 2028
     texi2html
... ...
@@ -2950,7 +2947,6 @@ pulse_indev_deps="libpulse"
2950 2950
 pulse_outdev_deps="libpulse"
2951 2951
 qtkit_indev_extralibs="-framework QTKit -framework Foundation -framework QuartzCore"
2952 2952
 qtkit_indev_select="qtkit"
2953
-sdl_outdev_deps="sdl"
2954 2953
 sdl2_outdev_deps="sdl2"
2955 2954
 sndio_indev_deps="sndio_h"
2956 2955
 sndio_outdev_deps="sndio_h"
... ...
@@ -5850,7 +5846,7 @@ if enabled gcrypt; then
5850 5850
     fi
5851 5851
 fi
5852 5852
 
5853
-if ! disabled sdl2 && ! enabled sdl; then
5853
+if ! disabled sdl2; then
5854 5854
     SDL2_CONFIG="${cross_prefix}sdl2-config"
5855 5855
     if check_pkg_config sdl2 SDL_events.h SDL_PollEvent; then
5856 5856
         check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x020001" $sdl2_cflags &&
... ...
@@ -5871,32 +5867,6 @@ if ! disabled sdl2 && ! enabled sdl; then
5871 5871
 fi
5872 5872
 enabled sdl2 && add_cflags $sdl2_cflags && add_extralibs $sdl2_libs
5873 5873
 
5874
-if ! disabled sdl && ! enabled sdl2; then
5875
-    SDL_CONFIG="${cross_prefix}sdl-config"
5876
-    if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
5877
-        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5878
-        check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5879
-        enable sdl
5880
-    else
5881
-        if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
5882
-            sdl_cflags=$("${SDL_CONFIG}" --cflags)
5883
-            sdl_libs=$("${SDL_CONFIG}" --libs)
5884
-            check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
5885
-            check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
5886
-            check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
5887
-            enable sdl
5888
-        elif enabled sdl ; then
5889
-            die "ERROR: SDL not found"
5890
-        else
5891
-            disable sdl
5892
-        fi
5893
-    fi
5894
-    if test $target_os = "mingw32"; then
5895
-        sdl_libs="$sdl_libs -mconsole"
5896
-    fi
5897
-fi
5898
-enabled sdl && add_cflags $sdl_cflags && add_extralibs $sdl_libs
5899
-
5900 5874
 disabled securetransport || { check_func SecIdentityCreate "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5901 5875
     check_lib2 "Security/SecureTransport.h Security/Security.h" "SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
5902 5876
     enable securetransport; }
... ...
@@ -6500,7 +6470,6 @@ echo "new filter support        ${avfilter-no}"
6500 6500
 echo "network support           ${network-no}"
6501 6501
 echo "threading support         ${thread_type-no}"
6502 6502
 echo "safe bitstream reader     ${safe_bitstream_reader-no}"
6503
-echo "SDL support               ${sdl-no}"
6504 6503
 echo "SDL2 support              ${sdl2-no}"
6505 6504
 echo "opencl enabled            ${opencl-no}"
6506 6505
 echo "JNI support               ${jni-no}"
... ...
@@ -40,7 +40,6 @@ OBJS-$(CONFIG_PULSE_INDEV)               += pulse_audio_dec.o \
40 40
 OBJS-$(CONFIG_PULSE_OUTDEV)              += pulse_audio_enc.o \
41 41
                                             pulse_audio_common.o
42 42
 OBJS-$(CONFIG_QTKIT_INDEV)               += qtkit.o
43
-OBJS-$(CONFIG_SDL_OUTDEV)                += sdl.o
44 43
 OBJS-$(CONFIG_SDL2_OUTDEV)               += sdl2.o
45 44
 OBJS-$(CONFIG_SNDIO_INDEV)               += sndio_dec.o sndio.o
46 45
 OBJS-$(CONFIG_SNDIO_OUTDEV)              += sndio_enc.o sndio.o
... ...
@@ -63,7 +63,6 @@ void avdevice_register_all(void)
63 63
     REGISTER_INOUTDEV(OSS,              oss);
64 64
     REGISTER_INOUTDEV(PULSE,            pulse);
65 65
     REGISTER_INDEV   (QTKIT,            qtkit);
66
-    REGISTER_OUTDEV  (SDL,              sdl);
67 66
     REGISTER_OUTDEV  (SDL2,             sdl2);
68 67
     REGISTER_INOUTDEV(SNDIO,            sndio);
69 68
     REGISTER_INOUTDEV(V4L2,             v4l2);
70 69
deleted file mode 100644
... ...
@@ -1,377 +0,0 @@
1
-/*
2
- * Copyright (c) 2011 Stefano Sabatini
3
- *
4
- * This file is part of FFmpeg.
5
- *
6
- * FFmpeg is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU Lesser General Public
8
- * License as published by the Free Software Foundation; either
9
- * version 2.1 of the License, or (at your option) any later version.
10
- *
11
- * FFmpeg is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
- * Lesser General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU Lesser General Public
17
- * License along with FFmpeg; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
- */
20
-
21
-/**
22
- * @file
23
- * libSDL output device
24
- */
25
-
26
-#include <SDL.h>
27
-#include <SDL_thread.h>
28
-
29
-#include "libavutil/avstring.h"
30
-#include "libavutil/imgutils.h"
31
-#include "libavutil/opt.h"
32
-#include "libavutil/parseutils.h"
33
-#include "libavutil/pixdesc.h"
34
-#include "libavutil/time.h"
35
-#include "avdevice.h"
36
-
37
-typedef struct {
38
-    AVClass *class;
39
-    SDL_Surface *surface;
40
-    SDL_Overlay *overlay;
41
-    char *window_title;
42
-    char *icon_title;
43
-    int window_width,  window_height;  /**< size of the window */
44
-    int window_fullscreen;
45
-
46
-    SDL_Rect overlay_rect;
47
-    int overlay_fmt;
48
-
49
-    int sdl_was_already_inited;
50
-    SDL_Thread *event_thread;
51
-    SDL_mutex *mutex;
52
-    SDL_cond *init_cond;
53
-    int init_ret; /* return code used to signal initialization errors */
54
-    int inited;
55
-    int quit;
56
-} SDLContext;
57
-
58
-static const struct sdl_overlay_pix_fmt_entry {
59
-    enum AVPixelFormat pix_fmt; int overlay_fmt;
60
-} sdl_overlay_pix_fmt_map[] = {
61
-    { AV_PIX_FMT_YUV420P, SDL_IYUV_OVERLAY },
62
-    { AV_PIX_FMT_YUYV422, SDL_YUY2_OVERLAY },
63
-    { AV_PIX_FMT_UYVY422, SDL_UYVY_OVERLAY },
64
-    { AV_PIX_FMT_NONE,    0                },
65
-};
66
-
67
-static int sdl_write_trailer(AVFormatContext *s)
68
-{
69
-    SDLContext *sdl = s->priv_data;
70
-
71
-    sdl->quit = 1;
72
-
73
-    if (sdl->overlay)
74
-        SDL_FreeYUVOverlay(sdl->overlay);
75
-    sdl->overlay = NULL;
76
-    if (sdl->event_thread)
77
-        SDL_WaitThread(sdl->event_thread, NULL);
78
-    sdl->event_thread = NULL;
79
-    if (sdl->mutex)
80
-        SDL_DestroyMutex(sdl->mutex);
81
-    sdl->mutex = NULL;
82
-    if (sdl->init_cond)
83
-        SDL_DestroyCond(sdl->init_cond);
84
-    sdl->init_cond = NULL;
85
-
86
-    if (!sdl->sdl_was_already_inited)
87
-        SDL_Quit();
88
-
89
-    return 0;
90
-}
91
-
92
-static void compute_overlay_rect(AVFormatContext *s)
93
-{
94
-    AVRational sar, dar; /* sample and display aspect ratios */
95
-    SDLContext *sdl = s->priv_data;
96
-    AVStream *st = s->streams[0];
97
-    AVCodecParameters *par = st->codecpar;
98
-    SDL_Rect *overlay_rect = &sdl->overlay_rect;
99
-
100
-    /* compute overlay width and height from the codec context information */
101
-    sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
102
-    dar = av_mul_q(sar, (AVRational){ par->width, par->height });
103
-
104
-    /* we suppose the screen has a 1/1 sample aspect ratio */
105
-    if (sdl->window_width && sdl->window_height) {
106
-        /* fit in the window */
107
-        if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
108
-            /* fit in width */
109
-            overlay_rect->w = sdl->window_width;
110
-            overlay_rect->h = av_rescale(overlay_rect->w, dar.den, dar.num);
111
-        } else {
112
-            /* fit in height */
113
-            overlay_rect->h = sdl->window_height;
114
-            overlay_rect->w = av_rescale(overlay_rect->h, dar.num, dar.den);
115
-        }
116
-    } else {
117
-        if (sar.num > sar.den) {
118
-            overlay_rect->w = par->width;
119
-            overlay_rect->h = av_rescale(overlay_rect->w, dar.den, dar.num);
120
-        } else {
121
-            overlay_rect->h = par->height;
122
-            overlay_rect->w = av_rescale(overlay_rect->h, dar.num, dar.den);
123
-        }
124
-        sdl->window_width  = overlay_rect->w;
125
-        sdl->window_height = overlay_rect->h;
126
-    }
127
-
128
-    overlay_rect->x = (sdl->window_width  - overlay_rect->w) / 2;
129
-    overlay_rect->y = (sdl->window_height - overlay_rect->h) / 2;
130
-}
131
-
132
-#define SDL_BASE_FLAGS (SDL_SWSURFACE|SDL_RESIZABLE)
133
-
134
-static int event_thread(void *arg)
135
-{
136
-    AVFormatContext *s = arg;
137
-    SDLContext *sdl = s->priv_data;
138
-    int flags = SDL_BASE_FLAGS | (sdl->window_fullscreen ? SDL_FULLSCREEN : 0);
139
-    AVStream *st = s->streams[0];
140
-    AVCodecParameters *par = st->codecpar;
141
-
142
-    /* initialization */
143
-    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
144
-        av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
145
-        sdl->init_ret = AVERROR(EINVAL);
146
-        goto init_end;
147
-    }
148
-
149
-    SDL_WM_SetCaption(sdl->window_title, sdl->icon_title);
150
-    sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height,
151
-                                    24, flags);
152
-    if (!sdl->surface) {
153
-        av_log(sdl, AV_LOG_ERROR, "Unable to set video mode: %s\n", SDL_GetError());
154
-        sdl->init_ret = AVERROR(EINVAL);
155
-        goto init_end;
156
-    }
157
-
158
-    sdl->overlay = SDL_CreateYUVOverlay(par->width, par->height,
159
-                                        sdl->overlay_fmt, sdl->surface);
160
-    if (!sdl->overlay || sdl->overlay->pitches[0] < par->width) {
161
-        av_log(s, AV_LOG_ERROR,
162
-               "SDL does not support an overlay with size of %dx%d pixels\n",
163
-               par->width, par->height);
164
-        sdl->init_ret = AVERROR(EINVAL);
165
-        goto init_end;
166
-    }
167
-
168
-    sdl->init_ret = 0;
169
-    av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n",
170
-           par->width, par->height, av_get_pix_fmt_name(par->format),
171
-           sdl->overlay_rect.w, sdl->overlay_rect.h);
172
-
173
-init_end:
174
-    SDL_LockMutex(sdl->mutex);
175
-    sdl->inited = 1;
176
-    SDL_UnlockMutex(sdl->mutex);
177
-    SDL_CondSignal(sdl->init_cond);
178
-
179
-    if (sdl->init_ret < 0)
180
-        return sdl->init_ret;
181
-
182
-    /* event loop */
183
-    while (!sdl->quit) {
184
-        int ret;
185
-        SDL_Event event;
186
-        SDL_PumpEvents();
187
-        ret = SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_ALLEVENTS);
188
-        if (ret < 0) {
189
-            av_log(s, AV_LOG_ERROR, "Error when getting SDL event: %s\n", SDL_GetError());
190
-            continue;
191
-        }
192
-        if (ret == 0) {
193
-            SDL_Delay(10);
194
-            continue;
195
-        }
196
-
197
-        switch (event.type) {
198
-        case SDL_KEYDOWN:
199
-            switch (event.key.keysym.sym) {
200
-            case SDLK_ESCAPE:
201
-            case SDLK_q:
202
-                sdl->quit = 1;
203
-                break;
204
-            }
205
-            break;
206
-        case SDL_QUIT:
207
-            sdl->quit = 1;
208
-            break;
209
-
210
-        case SDL_VIDEORESIZE:
211
-            sdl->window_width  = event.resize.w;
212
-            sdl->window_height = event.resize.h;
213
-
214
-            SDL_LockMutex(sdl->mutex);
215
-            sdl->surface = SDL_SetVideoMode(sdl->window_width, sdl->window_height, 24, SDL_BASE_FLAGS);
216
-            if (!sdl->surface) {
217
-                av_log(s, AV_LOG_ERROR, "Failed to set SDL video mode: %s\n", SDL_GetError());
218
-                sdl->quit = 1;
219
-            } else {
220
-                compute_overlay_rect(s);
221
-            }
222
-            SDL_UnlockMutex(sdl->mutex);
223
-            break;
224
-
225
-        default:
226
-            break;
227
-        }
228
-    }
229
-
230
-    return 0;
231
-}
232
-
233
-static int sdl_write_header(AVFormatContext *s)
234
-{
235
-    SDLContext *sdl = s->priv_data;
236
-    AVStream *st = s->streams[0];
237
-    AVCodecParameters *par = st->codecpar;
238
-    int i, ret;
239
-
240
-    if (!sdl->window_title)
241
-        sdl->window_title = av_strdup(s->filename);
242
-    if (!sdl->icon_title)
243
-        sdl->icon_title = av_strdup(sdl->window_title);
244
-
245
-    if (SDL_WasInit(SDL_INIT_VIDEO)) {
246
-        av_log(s, AV_LOG_ERROR,
247
-               "SDL video subsystem was already inited, aborting\n");
248
-        sdl->sdl_was_already_inited = 1;
249
-        ret = AVERROR(EINVAL);
250
-        goto fail;
251
-    }
252
-
253
-    if (   s->nb_streams > 1
254
-        || par->codec_type != AVMEDIA_TYPE_VIDEO
255
-        || par->codec_id   != AV_CODEC_ID_RAWVIDEO) {
256
-        av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
257
-        ret = AVERROR(EINVAL);
258
-        goto fail;
259
-    }
260
-
261
-    for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
262
-        if (sdl_overlay_pix_fmt_map[i].pix_fmt == par->format) {
263
-            sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
264
-            break;
265
-        }
266
-    }
267
-
268
-    if (!sdl->overlay_fmt) {
269
-        av_log(s, AV_LOG_ERROR,
270
-               "Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
271
-               av_get_pix_fmt_name(par->format));
272
-        ret = AVERROR(EINVAL);
273
-        goto fail;
274
-    }
275
-
276
-    /* compute overlay width and height from the codec context information */
277
-    compute_overlay_rect(s);
278
-
279
-    sdl->init_cond = SDL_CreateCond();
280
-    if (!sdl->init_cond) {
281
-        av_log(s, AV_LOG_ERROR, "Could not create SDL condition variable: %s\n", SDL_GetError());
282
-        ret = AVERROR_EXTERNAL;
283
-        goto fail;
284
-    }
285
-    sdl->mutex = SDL_CreateMutex();
286
-    if (!sdl->mutex) {
287
-        av_log(s, AV_LOG_ERROR, "Could not create SDL mutex: %s\n", SDL_GetError());
288
-        ret = AVERROR_EXTERNAL;
289
-        goto fail;
290
-    }
291
-    sdl->event_thread = SDL_CreateThread(event_thread, s);
292
-    if (!sdl->event_thread) {
293
-        av_log(s, AV_LOG_ERROR, "Could not create SDL event thread: %s\n", SDL_GetError());
294
-        ret = AVERROR_EXTERNAL;
295
-        goto fail;
296
-    }
297
-
298
-    /* wait until the video system has been inited */
299
-    SDL_LockMutex(sdl->mutex);
300
-    while (!sdl->inited) {
301
-        SDL_CondWait(sdl->init_cond, sdl->mutex);
302
-    }
303
-    SDL_UnlockMutex(sdl->mutex);
304
-    if (sdl->init_ret < 0) {
305
-        ret = sdl->init_ret;
306
-        goto fail;
307
-    }
308
-    return 0;
309
-
310
-fail:
311
-    sdl_write_trailer(s);
312
-    return ret;
313
-}
314
-
315
-static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
316
-{
317
-    SDLContext *sdl = s->priv_data;
318
-    AVCodecParameters *par = s->streams[0]->codecpar;
319
-    uint8_t *data[4];
320
-    int linesize[4];
321
-    int i;
322
-
323
-    if (sdl->quit) {
324
-        sdl_write_trailer(s);
325
-        return AVERROR(EIO);
326
-    }
327
-    av_image_fill_arrays(data, linesize, pkt->data, par->format, par->width, par->height, 1);
328
-
329
-    SDL_LockMutex(sdl->mutex);
330
-    SDL_FillRect(sdl->surface, &sdl->surface->clip_rect,
331
-                 SDL_MapRGB(sdl->surface->format, 0, 0, 0));
332
-    SDL_LockYUVOverlay(sdl->overlay);
333
-    for (i = 0; i < 3; i++) {
334
-        sdl->overlay->pixels [i] = data    [i];
335
-        sdl->overlay->pitches[i] = linesize[i];
336
-    }
337
-    SDL_DisplayYUVOverlay(sdl->overlay, &sdl->overlay_rect);
338
-    SDL_UnlockYUVOverlay(sdl->overlay);
339
-
340
-    SDL_UpdateRect(sdl->surface,
341
-                   sdl->overlay_rect.x, sdl->overlay_rect.y,
342
-                   sdl->overlay_rect.w, sdl->overlay_rect.h);
343
-    SDL_UnlockMutex(sdl->mutex);
344
-
345
-    return 0;
346
-}
347
-
348
-#define OFFSET(x) offsetof(SDLContext,x)
349
-
350
-static const AVOption options[] = {
351
-    { "window_title", "set SDL window title",           OFFSET(window_title), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
352
-    { "icon_title",   "set SDL iconified window title", OFFSET(icon_title)  , AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
353
-    { "window_size",  "set SDL window forced size",     OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
354
-    { "window_fullscreen", "set SDL window fullscreen", OFFSET(window_fullscreen), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
355
-    { NULL },
356
-};
357
-
358
-static const AVClass sdl_class = {
359
-    .class_name = "sdl outdev",
360
-    .item_name  = av_default_item_name,
361
-    .option     = options,
362
-    .version    = LIBAVUTIL_VERSION_INT,
363
-    .category   = AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT,
364
-};
365
-
366
-AVOutputFormat ff_sdl_muxer = {
367
-    .name           = "sdl",
368
-    .long_name      = NULL_IF_CONFIG_SMALL("SDL output device"),
369
-    .priv_data_size = sizeof(SDLContext),
370
-    .audio_codec    = AV_CODEC_ID_NONE,
371
-    .video_codec    = AV_CODEC_ID_RAWVIDEO,
372
-    .write_header   = sdl_write_header,
373
-    .write_packet   = sdl_write_packet,
374
-    .write_trailer  = sdl_write_trailer,
375
-    .flags          = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS,
376
-    .priv_class     = &sdl_class,
377
-};