GNU Radio 3.6.3 C++ API
video_sdl_sink_s.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_VIDEO_SDL_SINK_S_H
24 #define INCLUDED_VIDEO_SDL_SINK_S_H
25 
26 #include <video_sdl_api.h>
27 #include <gr_sync_block.h>
28 #include <string>
29 #include <SDL.h>
30 
31 /* fourcc (four character code) */
32 #define vid_fourcc(a,b,c,d) (((unsigned)(a)<<0) | ((unsigned)(b)<<8) | ((unsigned)(c)<<16) | ((unsigned)(d)<<24))
33 #define IMGFMT_YV12 vid_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */
34 
35 class video_sdl_sink_s;
37 
39 video_sdl_make_sink_s (double framerate,int width=640, int height=480,unsigned int format=IMGFMT_YV12,int dst_width=-1,int dst_height=-1);
40 
41 /*!
42  * \brief video sink using SDL
43  *
44  * input signature is one, two or three streams of signed short.
45  * One stream: stream is grey (Y)
46  * two streems: first is grey (Y), second is alternating U and V
47  * Three streams: first is grey (Y), second is U, third is V
48  * Input samples must be in the range [0,255].
49  */
50 
53  video_sdl_make_sink_s (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height);
54 
55  int d_chunk_size;
56 
57  protected:
58  video_sdl_sink_s (double framerate,int width, int height,unsigned int format,
59  int dst_width,int dst_height);
60  void copy_line_pixel_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,
61  const short * src_pixels,int src_width);
62  void copy_line_line_interleaved(unsigned char *dst_pixels_u,unsigned char *dst_pixels_v,
63  const short * src_pixels,int src_width);
64  void copy_line_single_plane(unsigned char *dst_pixels,const short * src_pixels,int src_width);
65  void copy_line_single_plane_dec2(unsigned char *dst_pixels,const short * src_pixels,int src_width);
66  int copy_plane_to_surface (int plane,int noutput_items,
67  const short * src_pixels);
68  float d_framerate;
70  int d_width;
71  int d_height;
74  int d_format;
76  SDL_Surface *d_screen;
77  SDL_Overlay *d_image;
78  SDL_Rect d_dst_rect;
79  float d_avg_delay;
80  unsigned int d_wanted_ticks;
81 
82 
83  public:
84  ~video_sdl_sink_s ();
85 
86  int work (int noutput_items,
87  gr_vector_const_void_star &input_items,
88  gr_vector_void_star &output_items);
89 };
90 
91 #endif /* INCLUDED_VIDEO_SDL_SINK_S_H */