2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /* some global constants for video MSFilter(s) */
26 #define MS_VIDEO_SIZE_SQCIF_W 128
27 #define MS_VIDEO_SIZE_SQCIF_H 96
28 #define MS_VIDEO_SIZE_QCIF_W 176
29 #define MS_VIDEO_SIZE_QCIF_H 144
30 #define MS_VIDEO_SIZE_CIF_W 352
31 #define MS_VIDEO_SIZE_CIF_H 288
32 #define MS_VIDEO_SIZE_ICIF_W 352
33 #define MS_VIDEO_SIZE_ICIF_H 576
34 #define MS_VIDEO_SIZE_4CIF_W 704
35 #define MS_VIDEO_SIZE_4CIF_H 576
37 #define MS_VIDEO_SIZE_QQVGA_W 160
38 #define MS_VIDEO_SIZE_QQVGA_H 120
39 #define MS_VIDEO_SIZE_QVGA_W 320
40 #define MS_VIDEO_SIZE_QVGA_H 240
41 #define MS_VIDEO_SIZE_VGA_W 640
42 #define MS_VIDEO_SIZE_VGA_H 480
43 #define MS_VIDEO_SIZE_SVGA_W 800
44 #define MS_VIDEO_SIZE_SVGA_H 600
46 #define MS_VIDEO_SIZE_NS1_W 324
47 #define MS_VIDEO_SIZE_NS1_H 248
49 #define MS_VIDEO_SIZE_QSIF_W 176
50 #define MS_VIDEO_SIZE_QSIF_H 120
51 #define MS_VIDEO_SIZE_SIF_W 352
52 #define MS_VIDEO_SIZE_SIF_H 240
53 #define MS_VIDEO_SIZE_ISIF_W 352
54 #define MS_VIDEO_SIZE_ISIF_H 480
55 #define MS_VIDEO_SIZE_4SIF_W 704
56 #define MS_VIDEO_SIZE_4SIF_H 480
58 #define MS_VIDEO_SIZE_288P_W 512
59 #define MS_VIDEO_SIZE_288P_H 288
60 #define MS_VIDEO_SIZE_448P_W 768
61 #define MS_VIDEO_SIZE_448P_H 448
62 #define MS_VIDEO_SIZE_576P_W 1024
63 #define MS_VIDEO_SIZE_576P_H 576
64 #define MS_VIDEO_SIZE_720P_W 1280
65 #define MS_VIDEO_SIZE_720P_H 720
66 #define MS_VIDEO_SIZE_1080P_W 1920
67 #define MS_VIDEO_SIZE_1080P_H 1080
69 #define MS_VIDEO_SIZE_SDTV_W 768
70 #define MS_VIDEO_SIZE_SDTV_H 576
71 #define MS_VIDEO_SIZE_HDTVP_W 1920
72 #define MS_VIDEO_SIZE_HDTVP_H 1200
74 #define MS_VIDEO_SIZE_XGA_W 1024
75 #define MS_VIDEO_SIZE_XGA_H 768
76 #define MS_VIDEO_SIZE_WXGA_W 1080
77 #define MS_VIDEO_SIZE_WXGA_H 768
79 #define MS_VIDEO_SIZE_MAX_W MS_VIDEO_SIZE_1024_W
80 #define MS_VIDEO_SIZE_MAX_H MS_VIDEO_SIZE_1024_H
83 /* those structs are part of the ABI: don't change their size otherwise binary plugins will be broken*/
85 typedef struct MSVideoSize{
89 typedef struct MSRect{
93 #define MS_VIDEO_SIZE_CIF (MSVideoSize){MS_VIDEO_SIZE_CIF_W,MS_VIDEO_SIZE_CIF_H}
94 #define MS_VIDEO_SIZE_QCIF (MSVideoSize){MS_VIDEO_SIZE_QCIF_W,MS_VIDEO_SIZE_QCIF_H}
95 #define MS_VIDEO_SIZE_4CIF (MSVideoSize){MS_VIDEO_SIZE_4CIF_W,MS_VIDEO_SIZE_4CIF_H}
97 #define MS_VIDEO_SIZE_QQVGA (MSVideoSize){MS_VIDEO_SIZE_QQVGA_W,MS_VIDEO_SIZE_QQVGA_H}
98 #define MS_VIDEO_SIZE_QVGA (MSVideoSize){MS_VIDEO_SIZE_QVGA_W,MS_VIDEO_SIZE_QVGA_H}
99 #define MS_VIDEO_SIZE_VGA (MSVideoSize){MS_VIDEO_SIZE_VGA_W,MS_VIDEO_SIZE_VGA_H}
101 #define MS_VIDEO_SIZE_720P (MSVideoSize){MS_VIDEO_SIZE_720P_W, MS_VIDEO_SIZE_720P_H}
103 #define MS_VIDEO_SIZE_NS1 (MSVideoSize){MS_VIDEO_SIZE_NS1_W,MS_VIDEO_SIZE_NS1_H}
105 #define MS_VIDEO_SIZE_XGA (MSVideoSize){MS_VIDEO_SIZE_XGA_W, MS_VIDEO_SIZE_XGA_H}
107 #define MS_VIDEO_SIZE_SVGA (MSVideoSize){MS_VIDEO_SIZE_SVGA_W, MS_VIDEO_SIZE_SVGA_H}
109 /*deprecated: use MS_VIDEO_SIZE_SVGA*/
110 #define MS_VIDEO_SIZE_800X600_W MS_VIDEO_SIZE_SVGA_W
111 #define MS_VIDEO_SIZE_800X600_H MS_VIDEO_SIZE_SVGA_H
112 #define MS_VIDEO_SIZE_800X600 MS_VIDEO_SIZE_SVGA
113 /*deprecated use MS_VIDEO_SIZE_XGA*/
114 #define MS_VIDEO_SIZE_1024_W 1024
115 #define MS_VIDEO_SIZE_1024_H 768
116 #define MS_VIDEO_SIZE_1024 MS_VIDEO_SIZE_XGA
122 MS_RGB24_REV, /*->microsoft down-top bitmaps */
125 MS_YUY2, /* -> same as MS_YUYV */
129 typedef struct _MSPicture{
131 uint8_t *planes[4]; /*we usually use 3 planes, 4th is for compatibility */
132 int strides[4]; /*with ffmpeg's swscale.h */
135 typedef struct _MSPicture YuvBuf; /*for backward compatibility*/
141 int ms_pix_fmt_to_ffmpeg(MSPixFmt fmt);
142 MSPixFmt ffmpeg_pix_fmt_to_ms(int fmt);
143 MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc);
144 void ms_ffmpeg_check_init(void);
145 int yuv_buf_init_from_mblk(MSPicture *buf, mblk_t *m);
146 void yuv_buf_init_from_mblk_with_size(MSPicture *buf, mblk_t *m, int w, int h);
147 mblk_t * yuv_buf_alloc(MSPicture *buf, int w, int h);
148 void yuv_buf_copy(uint8_t *src_planes[], const int src_strides[],
149 uint8_t *dst_planes[], const int dst_strides[3], MSVideoSize roi);
150 void yuv_buf_mirror(YuvBuf *buf);
151 void rgb24_revert(uint8_t *buf, int w, int h, int linesize);
152 void rgb24_copy_revert(uint8_t *dstbuf, int dstlsz,
153 const uint8_t *srcbuf, int srclsz, MSVideoSize roi);
155 static inline bool_t ms_video_size_greater_than(MSVideoSize vs1, MSVideoSize vs2){
156 return (vs1.width>=vs2.width) && (vs1.height>=vs2.height);
159 static inline MSVideoSize ms_video_size_max(MSVideoSize vs1, MSVideoSize vs2){
160 return ms_video_size_greater_than(vs1,vs2) ? vs1 : vs2;
163 static inline MSVideoSize ms_video_size_min(MSVideoSize vs1, MSVideoSize vs2){
164 return ms_video_size_greater_than(vs1,vs2) ? vs2 : vs1;
167 static inline bool_t ms_video_size_equal(MSVideoSize vs1, MSVideoSize vs2){
168 return vs1.width==vs2.width && vs1.height==vs2.height;
171 MSVideoSize ms_video_size_get_just_lower_than(MSVideoSize vs);
177 #define MS_FILTER_SET_VIDEO_SIZE MS_FILTER_BASE_METHOD(100,MSVideoSize)
178 #define MS_FILTER_GET_VIDEO_SIZE MS_FILTER_BASE_METHOD(101,MSVideoSize)
180 #define MS_FILTER_SET_PIX_FMT MS_FILTER_BASE_METHOD(102,MSPixFmt)
181 #define MS_FILTER_GET_PIX_FMT MS_FILTER_BASE_METHOD(103,MSPixFmt)
183 #define MS_FILTER_SET_FPS MS_FILTER_BASE_METHOD(104,float)
184 #define MS_FILTER_GET_FPS MS_FILTER_BASE_METHOD(105,float)
186 /* request a video-fast-update (=I frame for H263,MP4V-ES) to a video encoder*/
187 #define MS_FILTER_REQ_VFU MS_FILTER_BASE_METHOD_NO_ARG(106)
189 #define MS_FILTER_SET_IMAGE MS_FILTER_BASE_METHOD(107,char)