Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
a859bcff
Commit
a859bcff
authored
May 12, 2010
by
unknown
Browse files
add mirroring feature
parent
349a66db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
8 deletions
+59
-8
include/mediastreamer2/msinterfaces.h
include/mediastreamer2/msinterfaces.h
+1
-1
include/mediastreamer2/msvideo.h
include/mediastreamer2/msvideo.h
+1
-0
src/drawdib-display.c
src/drawdib-display.c
+37
-7
src/msvideo.c
src/msvideo.c
+20
-0
No files found.
include/mediastreamer2/msinterfaces.h
View file @
a859bcff
...
...
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** whether the video window should be resized to the stream's resolution*/
#define MS_VIDEO_DISPLAY_ENABLE_AUTOFIT \
MS_FILTER_METHOD(MSFilterVideoDisplayInterface,0,
bool_
t)
MS_FILTER_METHOD(MSFilterVideoDisplayInterface,0,
in
t)
/**position of the local view */
#define MS_VIDEO_DISPLAY_SET_LOCAL_VIEW_CORNER \
...
...
include/mediastreamer2/msvideo.h
View file @
a859bcff
...
...
@@ -149,6 +149,7 @@ mblk_t * yuv_buf_alloc(MSPicture *buf, int w, int h);
void
ms_yuv_buf_copy
(
uint8_t
*
src_planes
[],
const
int
src_strides
[],
uint8_t
*
dst_planes
[],
const
int
dst_strides
[
3
],
MSVideoSize
roi
);
void
ms_yuv_buf_mirror
(
YuvBuf
*
buf
);
void
rgb24_mirror
(
uint8_t
*
buf
,
int
w
,
int
h
,
int
linesize
);
void
rgb24_revert
(
uint8_t
*
buf
,
int
w
,
int
h
,
int
linesize
);
void
rgb24_copy_revert
(
uint8_t
*
dstbuf
,
int
dstlsz
,
const
uint8_t
*
srcbuf
,
int
srclsz
,
MSVideoSize
roi
);
...
...
src/drawdib-display.c
View file @
a859bcff
...
...
@@ -76,7 +76,7 @@ static void yuv2rgb_prepare(Yuv2RgbCtx *ctx, MSVideoSize src, MSVideoSize dst){
}
static
void
yuv2rgb_process
(
Yuv2RgbCtx
*
ctx
,
MSPicture
*
src
,
MSVideoSize
dstsize
){
static
void
yuv2rgb_process
(
Yuv2RgbCtx
*
ctx
,
MSPicture
*
src
,
MSVideoSize
dstsize
,
bool_t
mirroring
){
MSVideoSize
srcsize
;
srcsize
.
width
=
src
->
w
;
...
...
@@ -93,6 +93,7 @@ static void yuv2rgb_process(Yuv2RgbCtx *ctx, MSPicture *src, MSVideoSize dstsize
src
->
h
,
&
p
,
&
rgb_stride
)
<
0
){
ms_error
(
"Error in 420->rgb ms_sws_scale()."
);
}
if
(
mirroring
)
rgb24_mirror
(
ctx
->
rgb
,
dstsize
.
width
,
dstsize
.
height
,
dstsize
.
width
*
3
);
}
}
...
...
@@ -107,7 +108,7 @@ static void yuv2rgb_draw(Yuv2RgbCtx *ctx, HDRAWDIB ddh, HDC hdc, int dstx, int d
bi
.
biBitCount
=
24
;
bi
.
biCompression
=
BI_RGB
;
bi
.
biSizeImage
=
ctx
->
rgblen
;
DrawDibDraw
(
ddh
,
hdc
,
dstx
,
dsty
,
ctx
->
dsize
.
width
,
ctx
->
dsize
.
height
,
&
bi
,
ctx
->
rgb
,
DrawDibDraw
(
ddh
,
hdc
,
dstx
,
dsty
,
-
1
,
-
1
,
&
bi
,
ctx
->
rgb
,
0
,
0
,
ctx
->
dsize
.
width
,
ctx
->
dsize
.
height
,
0
);
}
}
...
...
@@ -120,6 +121,8 @@ typedef struct _DDDisplay{
Yuv2RgbCtx
mainview
;
Yuv2RgbCtx
locview
;
bool_t
need_repaint
;
bool_t
autofit
;
bool_t
mirroring
;
}
DDDisplay
;
static
LRESULT
CALLBACK
window_proc
(
...
...
@@ -208,6 +211,8 @@ static void dd_display_init(MSFilter *f){
yuv2rgb_init
(
&
obj
->
mainview
);
yuv2rgb_init
(
&
obj
->
locview
);
obj
->
need_repaint
=
FALSE
;
obj
->
autofit
=
TRUE
;
obj
->
mirroring
=
FALSE
;
f
->
data
=
obj
;
}
...
...
@@ -352,6 +357,15 @@ static void dd_display_process(MSFilter *f){
if
(
f
->
inputs
[
0
]
!=
NULL
&&
(
main_im
=
ms_queue_peek_last
(
f
->
inputs
[
0
]))
!=
NULL
)
{
if
(
yuv_buf_init_from_mblk
(
&
mainpic
,
main_im
)
==
0
){
if
(
obj
->
autofit
&&
(
obj
->
vsize
.
width
!=
mainpic
.
w
||
obj
->
vsize
.
height
!=
mainpic
.
h
)
&&
(
mainpic
.
w
>
wsize
.
width
||
mainpic
.
h
>
wsize
.
height
)){
RECT
cur
;
ms_message
(
"Detected video resolution changed, resizing window"
);
GetWindowRect
(
obj
->
window
,
&
cur
);
wsize
.
width
=
mainpic
.
w
;
wsize
.
height
=
mainpic
.
h
;
MoveWindow
(
obj
->
window
,
cur
.
left
,
cur
.
top
,
wsize
.
width
,
wsize
.
height
,
TRUE
);
}
obj
->
vsize
.
width
=
mainpic
.
w
;
obj
->
vsize
.
height
=
mainpic
.
h
;
}
...
...
@@ -363,10 +377,10 @@ static void dd_display_process(MSFilter *f){
lsize
.
height
=
localrect
.
h
;
if
(
local_im
!=
NULL
)
yuv2rgb_process
(
&
obj
->
locview
,
&
localpic
,
lsize
);
yuv2rgb_process
(
&
obj
->
locview
,
&
localpic
,
lsize
,
!
mblk_get_precious_flag
(
local_im
)
);
if
(
main_im
!=
NULL
)
yuv2rgb_process
(
&
obj
->
mainview
,
&
mainpic
,
vsize
);
yuv2rgb_process
(
&
obj
->
mainview
,
&
mainpic
,
vsize
,
obj
->
mirroring
&&
!
mblk_get_precious_flag
(
main_im
)
);
hdc
=
GetDC
(
obj
->
window
);
if
(
hdc
==
NULL
)
{
...
...
@@ -384,8 +398,10 @@ static void dd_display_process(MSFilter *f){
}
if
(
local_im
!=
NULL
||
main_im
!=
NULL
){
draw_local_view_frame
(
hdc
,
wsize
,
localrect
);
yuv2rgb_draw
(
&
obj
->
locview
,
obj
->
ddh
,
hdc
,
localrect
.
x
,
localrect
.
y
);
if
(
obj
->
locview
.
rgb
!=
NULL
){
draw_local_view_frame
(
hdc
,
wsize
,
localrect
);
yuv2rgb_draw
(
&
obj
->
locview
,
obj
->
ddh
,
hdc
,
localrect
.
x
,
localrect
.
y
);
}
}
ReleaseDC
(
NULL
,
hdc
);
...
...
@@ -401,8 +417,22 @@ static int get_native_window_id(MSFilter *f, void *data){
return
0
;
}
static
int
enable_autofit
(
MSFilter
*
f
,
void
*
data
){
DDDisplay
*
obj
=
(
DDDisplay
*
)
f
->
data
;
obj
->
autofit
=*
(
int
*
)
data
;
return
0
;
}
static
int
enable_mirroring
(
MSFilter
*
f
,
void
*
data
){
DDDisplay
*
obj
=
(
DDDisplay
*
)
f
->
data
;
obj
->
mirroring
=*
(
int
*
)
data
;
return
0
;
}
static
MSFilterMethod
methods
[]
=
{
{
MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID
,
get_native_window_id
},
{
MS_VIDEO_DISPLAY_ENABLE_AUTOFIT
,
enable_autofit
},
{
MS_VIDEO_DISPLAY_ENABLE_MIRRORING
,
enable_mirroring
},
{
0
,
NULL
}
};
...
...
src/msvideo.c
View file @
a859bcff
...
...
@@ -197,6 +197,26 @@ MSPixFmt ms_fourcc_to_pix_fmt(uint32_t fourcc){
return
ret
;
}
void
rgb24_mirror
(
uint8_t
*
buf
,
int
w
,
int
h
,
int
linesize
){
int
i
,
j
;
int
r
,
g
,
b
;
int
end
=
w
*
3
;
for
(
i
=
0
;
i
<
h
;
++
i
){
for
(
j
=
0
;
j
<
end
/
2
;
j
+=
3
){
r
=
buf
[
j
];
g
=
buf
[
j
+
1
];
b
=
buf
[
j
+
2
];
buf
[
j
]
=
buf
[
end
-
j
-
3
];
buf
[
j
+
1
]
=
buf
[
end
-
j
-
2
];
buf
[
j
+
2
]
=
buf
[
end
-
j
-
1
];
buf
[
end
-
j
-
3
]
=
r
;
buf
[
end
-
j
-
2
]
=
g
;
buf
[
end
-
j
-
1
]
=
b
;
}
buf
+=
linesize
;
}
}
void
rgb24_revert
(
uint8_t
*
buf
,
int
w
,
int
h
,
int
linesize
){
uint8_t
*
p
,
*
pe
;
int
i
,
j
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment