FFmpeg
sdl2.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Josh de Kock
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  * libSDL2 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 #include "libavformat/mux.h"
37 
38 typedef struct {
39  AVClass *class;
40  SDL_Window *window;
41  SDL_Renderer *renderer;
42  char *window_title;
43  int window_width, window_height; /**< size of the window */
44  int window_x, window_y; /**< position of the window */
48 
49  SDL_Texture *texture;
51  SDL_Rect texture_rect;
52 
53  int inited;
54  int warned;
55 } SDLContext;
56 
57 static const struct sdl_texture_format_entry {
60  /*
61  * Not implemented in FFmpeg, but leaving here for completeness.
62  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB4444 },
63  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_RGBA4444 },
64  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ABGR4444 },
65  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_BGRA4444 },
66  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB1555 },
67  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_RGBA5551 },
68  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ABGR1555 },
69  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_BGRA5551 },
70  * { AV_PIX_FMT_NONE, SDL_PIXELFORMAT_ARGB2101010 },
71  */
72  { AV_PIX_FMT_RGB8, SDL_PIXELFORMAT_RGB332 },
73  { AV_PIX_FMT_RGB444, SDL_PIXELFORMAT_RGB444 },
74  { AV_PIX_FMT_RGB555, SDL_PIXELFORMAT_RGB555 },
75  { AV_PIX_FMT_BGR555, SDL_PIXELFORMAT_BGR555 },
76  { AV_PIX_FMT_RGB565, SDL_PIXELFORMAT_RGB565 },
77  { AV_PIX_FMT_BGR565, SDL_PIXELFORMAT_BGR565 },
78  { AV_PIX_FMT_RGB24, SDL_PIXELFORMAT_RGB24 },
79  { AV_PIX_FMT_BGR24, SDL_PIXELFORMAT_BGR24 },
80  { AV_PIX_FMT_0RGB32, SDL_PIXELFORMAT_RGB888 },
81  { AV_PIX_FMT_0BGR32, SDL_PIXELFORMAT_BGR888 },
82 #if HAVE_BIGENDIAN
83  { AV_PIX_FMT_RGB0, SDL_PIXELFORMAT_RGBX8888 },
84  { AV_PIX_FMT_BGR0, SDL_PIXELFORMAT_BGRX8888 },
85 #else
86  { AV_PIX_FMT_0BGR, SDL_PIXELFORMAT_RGBX8888 },
87  { AV_PIX_FMT_0RGB, SDL_PIXELFORMAT_BGRX8888 },
88 #endif
89  { AV_PIX_FMT_RGB32, SDL_PIXELFORMAT_ARGB8888 },
90  { AV_PIX_FMT_RGB32_1, SDL_PIXELFORMAT_RGBA8888 },
91  { AV_PIX_FMT_BGR32, SDL_PIXELFORMAT_ABGR8888 },
92  { AV_PIX_FMT_BGR32_1, SDL_PIXELFORMAT_BGRA8888 },
93  { AV_PIX_FMT_YUV420P, SDL_PIXELFORMAT_IYUV },
94  { AV_PIX_FMT_YUYV422, SDL_PIXELFORMAT_YUY2 },
95  { AV_PIX_FMT_UYVY422, SDL_PIXELFORMAT_UYVY },
96  { AV_PIX_FMT_NONE, 0 },
97 };
98 
100 {
101  AVRational sar, dar; /* sample and display aspect ratios */
102  SDLContext *sdl = s->priv_data;
103  AVStream *st = s->streams[0];
104  AVCodecParameters *codecpar = st->codecpar;
105  SDL_Rect *texture_rect = &sdl->texture_rect;
106 
107  /* compute texture width and height from the codec context information */
108  sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
109  dar = av_mul_q(sar, (AVRational){ codecpar->width, codecpar->height });
110 
111  /* we suppose the screen has a 1/1 sample aspect ratio */
112  if (sdl->window_width && sdl->window_height) {
113  /* fit in the window */
114  if (av_cmp_q(dar, (AVRational){ sdl->window_width, sdl->window_height }) > 0) {
115  /* fit in width */
116  texture_rect->w = sdl->window_width;
117  texture_rect->h = av_rescale(texture_rect->w, dar.den, dar.num);
118  } else {
119  /* fit in height */
120  texture_rect->h = sdl->window_height;
121  texture_rect->w = av_rescale(texture_rect->h, dar.num, dar.den);
122  }
123  } else {
124  if (sar.num > sar.den) {
125  texture_rect->w = codecpar->width;
126  texture_rect->h = av_rescale(texture_rect->w, dar.den, dar.num);
127  } else {
128  texture_rect->h = codecpar->height;
129  texture_rect->w = av_rescale(texture_rect->h, dar.num, dar.den);
130  }
131  sdl->window_width = texture_rect->w;
132  sdl->window_height = texture_rect->h;
133  }
134 
135  texture_rect->x = (sdl->window_width - texture_rect->w) / 2;
136  texture_rect->y = (sdl->window_height - texture_rect->h) / 2;
137 }
138 
140 {
141  SDLContext *sdl = s->priv_data;
142 
143  if (sdl->texture)
144  SDL_DestroyTexture(sdl->texture);
145  sdl->texture = NULL;
146 
147  if (sdl->renderer)
148  SDL_DestroyRenderer(sdl->renderer);
149  sdl->renderer = NULL;
150 
151  if (sdl->window)
152  SDL_DestroyWindow(sdl->window);
153  sdl->window = NULL;
154 
155  if (!sdl->inited)
156  SDL_Quit();
157 
158  return 0;
159 }
160 
162 {
163  SDLContext *sdl = s->priv_data;
164  AVStream *st = s->streams[0];
165  AVCodecParameters *codecpar = st->codecpar;
166  int i, ret = 0;
167  int flags = 0;
168 
169  if (!sdl->warned) {
170  av_log(sdl, AV_LOG_WARNING,
171  "The sdl output device is deprecated due to being fundamentally incompatible with libavformat API. "
172  "For monitoring purposes in ffmpeg you can output to a file or use pipes and a video player.\n"
173  "Example: ffmpeg -i INPUT -f nut -c:v rawvideo - | ffplay -\n"
174  );
175  sdl->warned = 1;
176  }
177 
178  if (!sdl->window_title)
179  sdl->window_title = av_strdup(s->url);
180 
181  if (SDL_WasInit(SDL_INIT_VIDEO)) {
183  "SDL video subsystem was already inited, you could have multiple SDL outputs. This may cause unknown behaviour.\n");
184  sdl->inited = 1;
185  }
186 
187  if ( s->nb_streams > 1
188  || codecpar->codec_type != AVMEDIA_TYPE_VIDEO
189  || codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
190  av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
191  goto fail;
192  }
193 
194  for (i = 0; sdl_texture_format_map[i].format != AV_PIX_FMT_NONE; i++) {
195  if (sdl_texture_format_map[i].format == codecpar->format) {
197  break;
198  }
199  }
200 
201  if (!sdl->texture_fmt) {
203  "Unsupported pixel format '%s'.\n",
204  av_get_pix_fmt_name(codecpar->format));
205  goto fail;
206  }
207 
208  /* resize texture to width and height from the codec context information */
209  flags = SDL_WINDOW_HIDDEN |
210  (sdl->window_fullscreen ? SDL_WINDOW_FULLSCREEN : 0) |
211  (sdl->window_borderless ? SDL_WINDOW_BORDERLESS : SDL_WINDOW_RESIZABLE);
212 
213  /* initialization */
214  if (!sdl->inited){
215  if (SDL_Init(SDL_INIT_VIDEO) != 0) {
216  av_log(s, AV_LOG_ERROR, "Unable to initialize SDL: %s\n", SDL_GetError());
217  goto fail;
218  }
219  }
220 
222 
223  if (SDL_CreateWindowAndRenderer(sdl->window_width, sdl->window_height,
224  flags, &sdl->window, &sdl->renderer) != 0){
225  av_log(sdl, AV_LOG_ERROR, "Couldn't create window and renderer: %s\n", SDL_GetError());
226  goto fail;
227  }
228 
229  SDL_SetWindowTitle(sdl->window, sdl->window_title);
230  SDL_SetWindowPosition(sdl->window, sdl->window_x, sdl->window_y);
231  SDL_ShowWindow(sdl->window);
232 
233  sdl->texture = SDL_CreateTexture(sdl->renderer, sdl->texture_fmt, SDL_TEXTUREACCESS_STREAMING,
234  codecpar->width, codecpar->height);
235 
236  if (!sdl->texture) {
237  av_log(sdl, AV_LOG_ERROR, "Unable to set create mode: %s\n", SDL_GetError());
238  goto fail;
239  }
240 
241  av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n",
242  codecpar->width, codecpar->height, av_get_pix_fmt_name(codecpar->format),
243  sdl->window_width, sdl->window_height);
244 
245  sdl->inited = 1;
246 
247  return 0;
248 fail:
250  return ret;
251 }
252 
254 {
255  int ret, quit = 0;
256  SDLContext *sdl = s->priv_data;
257  AVCodecParameters *codecpar = s->streams[0]->codecpar;
258  uint8_t *data[4];
259  int linesize[4];
260 
261  SDL_Event event;
262  if (SDL_PollEvent(&event)){
263  switch (event.type) {
264  case SDL_KEYDOWN:
265  switch (event.key.keysym.sym) {
266  case SDLK_ESCAPE:
267  case SDLK_q:
268  quit = 1;
269  break;
270  default:
271  break;
272  }
273  break;
274  case SDL_QUIT:
275  quit = 1;
276  break;
277  case SDL_WINDOWEVENT:
278  switch(event.window.event){
279  case SDL_WINDOWEVENT_RESIZED:
280  case SDL_WINDOWEVENT_SIZE_CHANGED:
281  sdl->window_width = event.window.data1;
282  sdl->window_height = event.window.data2;
284  break;
285  default:
286  break;
287  }
288  break;
289  default:
290  break;
291  }
292  }
293 
294  if (quit && sdl->enable_quit_action) {
296  return AVERROR(EIO);
297  }
298 
299  av_image_fill_arrays(data, linesize, pkt->data, codecpar->format, codecpar->width, codecpar->height, 1);
300  switch (sdl->texture_fmt) {
301  /* case SDL_PIXELFORMAT_ARGB4444:
302  * case SDL_PIXELFORMAT_RGBA4444:
303  * case SDL_PIXELFORMAT_ABGR4444:
304  * case SDL_PIXELFORMAT_BGRA4444:
305  * case SDL_PIXELFORMAT_ARGB1555:
306  * case SDL_PIXELFORMAT_RGBA5551:
307  * case SDL_PIXELFORMAT_ABGR1555:
308  * case SDL_PIXELFORMAT_BGRA5551:
309  * case SDL_PIXELFORMAT_ARGB2101010:
310  */
311  case SDL_PIXELFORMAT_IYUV:
312  case SDL_PIXELFORMAT_YUY2:
313  case SDL_PIXELFORMAT_UYVY:
314  ret = SDL_UpdateYUVTexture(sdl->texture, NULL,
315  data[0], linesize[0],
316  data[1], linesize[1],
317  data[2], linesize[2]);
318  break;
319  case SDL_PIXELFORMAT_RGB332:
320  case SDL_PIXELFORMAT_RGB444:
321  case SDL_PIXELFORMAT_RGB555:
322  case SDL_PIXELFORMAT_BGR555:
323  case SDL_PIXELFORMAT_RGB565:
324  case SDL_PIXELFORMAT_BGR565:
325  case SDL_PIXELFORMAT_RGB24:
326  case SDL_PIXELFORMAT_BGR24:
327  case SDL_PIXELFORMAT_RGB888:
328  case SDL_PIXELFORMAT_RGBX8888:
329  case SDL_PIXELFORMAT_BGR888:
330  case SDL_PIXELFORMAT_BGRX8888:
331  case SDL_PIXELFORMAT_ARGB8888:
332  case SDL_PIXELFORMAT_RGBA8888:
333  case SDL_PIXELFORMAT_ABGR8888:
334  case SDL_PIXELFORMAT_BGRA8888:
335  ret = SDL_UpdateTexture(sdl->texture, NULL, data[0], linesize[0]);
336  break;
337  default:
338  av_log(NULL, AV_LOG_FATAL, "Unsupported pixel format\n");
339  ret = -1;
340  break;
341  }
342  SDL_RenderClear(sdl->renderer);
343  SDL_RenderCopy(sdl->renderer, sdl->texture, NULL, &sdl->texture_rect);
344  SDL_RenderPresent(sdl->renderer);
345  return ret;
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  { "window_size", "set SDL window forced size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
353  { "window_x", "set SDL window x position", OFFSET(window_x), AV_OPT_TYPE_INT, { .i64 = SDL_WINDOWPOS_CENTERED }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
354  { "window_y", "set SDL window y position", OFFSET(window_y), AV_OPT_TYPE_INT, { .i64 = SDL_WINDOWPOS_CENTERED }, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM },
355  { "window_fullscreen", "set SDL window fullscreen", OFFSET(window_fullscreen), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
356  { "window_borderless", "set SDL window border off", OFFSET(window_borderless), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
357  { "window_enable_quit", "set if quit action is available", OFFSET(enable_quit_action), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
358  { NULL },
359 };
360 
361 static const AVClass sdl2_class = {
362  .class_name = "sdl2 outdev",
363  .item_name = av_default_item_name,
364  .option = options,
365  .version = LIBAVUTIL_VERSION_INT,
367 };
368 
370  .p.name = "sdl,sdl2",
371  .p.long_name = NULL_IF_CONFIG_SMALL("SDL2 output device"),
372  .priv_data_size = sizeof(SDLContext),
373  .p.audio_codec = AV_CODEC_ID_NONE,
374  .p.video_codec = AV_CODEC_ID_RAWVIDEO,
375  .write_header = sdl2_write_header,
376  .write_packet = sdl2_write_packet,
377  .write_trailer = sdl2_write_trailer,
379  .p.priv_class = &sdl2_class,
380 };
sdl_texture_format_entry::texture_fmt
int texture_fmt
Definition: sdl2.c:58
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
SDLContext
Definition: sdl2.c:38
AVOutputFormat::name
const char * name
Definition: avformat.h:510
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
SDLContext::window_height
int window_height
size of the window
Definition: sdl2.c:43
AV_PIX_FMT_BGR32
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:453
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
AVFMT_VARIABLE_FPS
#define AVFMT_VARIABLE_FPS
Format allows variable fps.
Definition: avformat.h:482
sdl_texture_format_map
static const struct sdl_texture_format_entry sdl_texture_format_map[]
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:479
SDLContext::warned
int warned
Definition: sdl2.c:54
AV_CODEC_ID_RAWVIDEO
@ AV_CODEC_ID_RAWVIDEO
Definition: codec_id.h:65
SDLContext::texture_rect
SDL_Rect texture_rect
Definition: sdl2.c:51
pixdesc.h
SDLContext::window_x
int window_x
Definition: sdl2.c:44
AVPacket::data
uint8_t * data
Definition: packet.h:522
AVOption
AVOption.
Definition: opt.h:346
SDLContext::window_y
int window_y
position of the window
Definition: sdl2.c:44
data
const char data[16]
Definition: mxf.c:148
AV_PIX_FMT_RGB32_1
#define AV_PIX_FMT_RGB32_1
Definition: pixfmt.h:452
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
sdl2_class
static const AVClass sdl2_class
Definition: sdl2.c:361
FFOutputFormat::p
AVOutputFormat p
The public AVOutputFormat.
Definition: mux.h:65
SDLContext::window_fullscreen
int window_fullscreen
Definition: sdl2.c:45
sdl_texture_format_entry
Definition: sdl2.c:57
SDLContext::window
SDL_Window * window
Definition: sdl2.c:40
fail
#define fail()
Definition: checkasm.h:179
AVRational::num
int num
Numerator.
Definition: rational.h:59
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
s
#define s(width, name)
Definition: cbs_vp9.c:198
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AV_PIX_FMT_0BGR32
#define AV_PIX_FMT_0BGR32
Definition: pixfmt.h:456
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
AV_PIX_FMT_BGR32_1
#define AV_PIX_FMT_BGR32_1
Definition: pixfmt.h:454
window_title
static const char * window_title
Definition: ffplay.c:310
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUYV422
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:74
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
offset must point to two consecutive integers
Definition: opt.h:245
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
parseutils.h
AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
@ AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT
Definition: log.h:40
SDLContext::window_borderless
int window_borderless
Definition: sdl2.c:46
FFOutputFormat
Definition: mux.h:61
AV_PIX_FMT_RGB8
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
Definition: pixfmt.h:93
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
time.h
SDLContext::enable_quit_action
int enable_quit_action
Definition: sdl2.c:47
ff_sdl2_muxer
const FFOutputFormat ff_sdl2_muxer
Definition: sdl2.c:369
SDLContext::window_title
char * window_title
Definition: sdl2.c:42
SDLContext::texture
SDL_Texture * texture
Definition: sdl2.c:49
AV_OPT_FLAG_ENCODING_PARAM
#define AV_OPT_FLAG_ENCODING_PARAM
A generic parameter which can be set by the user for muxing or encoding.
Definition: opt.h:269
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
av_image_fill_arrays
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array.
Definition: imgutils.c:446
AV_PIX_FMT_BGR555
#define AV_PIX_FMT_BGR555
Definition: pixfmt.h:471
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:468
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:821
avdevice.h
compute_texture_rect
static void compute_texture_rect(AVFormatContext *s)
Definition: sdl2.c:99
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:451
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
SDLContext::window_width
int window_width
Definition: sdl2.c:43
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCodecParameters::height
int height
Definition: codec_par.h:135
options
static const AVOption options[]
Definition: sdl2.c:350
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:466
AV_PIX_FMT_BGR565
#define AV_PIX_FMT_BGR565
Definition: pixfmt.h:470
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
sdl_texture_format_entry::format
enum AVPixelFormat format
Definition: sdl2.c:58
OFFSET
#define OFFSET(x)
Definition: sdl2.c:348
AV_PIX_FMT_RGB565
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:465
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
SDLContext::inited
int inited
Definition: sdl2.c:53
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_0RGB32
Definition: pixfmt.h:455
SDLContext::renderer
SDL_Renderer * renderer
Definition: sdl2.c:41
AV_PIX_FMT_UYVY422
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:88
AVRational::den
int den
Denominator.
Definition: rational.h:60
sdl2_write_header
static int sdl2_write_header(AVFormatContext *s)
Definition: sdl2.c:161
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecParameters::format
int format
Definition: codec_par.h:92
sdl2_write_trailer
static int sdl2_write_trailer(AVFormatContext *s)
Definition: sdl2.c:139
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:499
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
SDLContext::texture_fmt
int texture_fmt
Definition: sdl2.c:50
sdl2_write_packet
static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: sdl2.c:253
avstring.h
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2882
mux.h
AV_PIX_FMT_RGB444
#define AV_PIX_FMT_RGB444
Definition: pixfmt.h:467