Commit 754c5cfe authored by Simon Morlat's avatar Simon Morlat
Browse files

Merge branch 'dev_android_video' of git.linphone.org:mediastreamer2-private into dev_android_video

parents ae2bac24 839d3b20
......@@ -124,7 +124,7 @@ AC_DEFUN([MS_CHECK_VIDEO],[
yes) enable_sdl=true ;;
no) enable_sdl=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-sdl) ;;
esac],[enable_sdl=true])
esac],[enable_sdl=false])
sdl_found=no
if test "$enable_sdl" = "true"; then
......
ANDROID_SRC_FILES= \
msandroid.cpp \
android-display.c \
android-display-bad.c \
msandroidvideo.cpp
EXTRA_DIST= winsnd2.c winsnd.c winvideo.c \
winvideods.c wincevideods.c dxfilter.h dxfilter.cpp \
msfileplayer_win.c msfilerec_win.c winsndds.cpp nowebcamCIF.jpg winsnd3.c vfw-missing.h \
winvideo2.c msjava.c
winvideo2.c msjava.c $(ANDROID_SRC_FILES)
BUILT_SOURCES=alldescs.h
......
......@@ -247,7 +247,28 @@ static void video_capture_process(MSFilter *f){
static void rotate_plane(int w, int h, uint8_t* src, int src_stride, uint8_t* dst, int dst_stride, int step) {
static void rotate_plane(int wDest, int hDest, uint8_t* src, uint8_t* dst, int step) {
int hSrc = wDest;
int wSrc = hDest;
int src_stride = wSrc * step;
int dst_stride = wDest;
dst += wDest;
for (int y=0; y<hSrc; y++) {
uint8_t* dst2 = dst;
for (int x=0; x<step*wSrc; x+=step) {
// Copy a line in source buffer (left to right)
// Store a column in destination buffer (top to bottom)
*dst2 = src[x];
dst2 += dst_stride;
}
dst--;
src += src_stride;
}
}
static void rotate_plane_with_stripes(int w, int h, uint8_t* src, int src_stride, uint8_t* dst, int dst_stride, int step) {
int alpha = (w-h) / 2; // the stripe
dst += alpha + h;
......@@ -264,6 +285,7 @@ static void rotate_plane(int w, int h, uint8_t* src, int src_stride, uint8_t* ds
src += src_stride;
}
}
static mblk_t *copy_frame_to_true_yuv(jbyte* initial_frame, int orientation, int w, int h) {
//ms_message("Orientation %i; width %i; heigth %i", orientation, w, h);
......@@ -286,7 +308,7 @@ static mblk_t *copy_frame_to_true_yuv(jbyte* initial_frame, int orientation, int
break;
case 1: // <--
memset(dsty, 16, ysize);
rotate_plane(w,h,srcy,w,dsty,w, 1);
rotate_plane_with_stripes(w,h,srcy,w,dsty,w, 1);
break;
case 0: // ^^^
memcpy(pict.planes[0],srcy,ysize);
......@@ -307,8 +329,8 @@ static mblk_t *copy_frame_to_true_yuv(jbyte* initial_frame, int orientation, int
int uvw = w/2;
int uvh = h/2;
rotate_plane(uvw,uvh,srcuv,w,dstu,uvw, 2);
rotate_plane(uvw,uvh,srcuv +1,w,dstv,uvw, 2);
rotate_plane_with_stripes(uvw,uvh,srcuv,w,dstu,uvw, 2);
rotate_plane_with_stripes(uvw,uvh,srcuv +1,w,dstv,uvw, 2);
break;
}
case 0:
......@@ -332,8 +354,44 @@ static mblk_t *copy_frame_to_true_yuv(jbyte* initial_frame, int orientation, int
return yuv_block;
}
static void drawGradient(int w, int h, uint8_t* dst, bool vertical) {
for (int y=0; y<h; y++) {
for (int x=0; x < w; x++) {
*(dst++) = vertical ? x : y;
}
}
}
// Destination and source images have their dimensions inverted.
static mblk_t *copy_frame_to_true_yuv_inverted(jbyte* initial_frame, int orientation, int w, int h) {
ms_message("copy_frame_to_true_yuv_inverted : Orientation %i; width %i; height %i", orientation, w, h);
MSPicture pict;
mblk_t *yuv_block = ms_yuv_buf_alloc(&pict, w, h);
// Copying Y
uint8_t* dsty = pict.planes[0];
uint8_t* srcy = (uint8_t*) initial_frame;
rotate_plane(w,h,srcy,dsty,1);
int uv_w = w/2;
int uv_h = h/2;
uint8_t* srcu = (uint8_t*) initial_frame + (w * h);
uint8_t* dstu = pict.planes[2];
rotate_plane(uv_w,uv_h,srcu,dstu, 2);
uint8_t* srcv = srcu + 1;
uint8_t* dstv = pict.planes[1];
rotate_plane(uv_w,uv_h,srcv,dstv, 2);
return yuv_block;
}
extern "C" void Java_org_linphone_core_AndroidCameraRecordImpl_putImage(JNIEnv* env,
jobject thiz,jlong nativePtr,jbyteArray jbadyuvframe, jint jorientation) {
jobject thiz,jlong nativePtr,jbyteArray jbadyuvframe, jint jorientation, jboolean invertedVideo) {
AndroidReaderContext* d = ((AndroidReaderContext*) nativePtr);
......@@ -345,7 +403,12 @@ extern "C" void Java_org_linphone_core_AndroidCameraRecordImpl_putImage(JNIEnv*
// Get a copy of the frame, encoded in a non interleaved YUV format
mblk_t *yuv_frame=copy_frame_to_true_yuv(jinternal_buff, (int) jorientation, d->vsize.width, d->vsize.height);
mblk_t *yuv_frame;
if (invertedVideo) {
yuv_frame=copy_frame_to_true_yuv_inverted(jinternal_buff, (int) jorientation, d->vsize.width, d->vsize.height);
} else {
yuv_frame=copy_frame_to_true_yuv(jinternal_buff, (int) jorientation, d->vsize.width, d->vsize.height);
}
ms_mutex_lock(&d->mutex);
......
......@@ -278,6 +278,8 @@ static void prepare(EncState *s){
c->strict_std_compliance=-2;
}
ms_message("Codec size set to w=%i/h=%i",c->width, c->height);
}
static void prepare_h263(EncState *s){
......@@ -844,6 +846,11 @@ static int enc_set_br(MSFilter *f, void *arg){
s->vsize.height=MS_VIDEO_SIZE_CIF_H;
s->fps=15;
s->qmin=3;
}else if (s->maxbr>=170000){
s->vsize.width=MS_VIDEO_SIZE_QVGA_W;
s->vsize.height=MS_VIDEO_SIZE_QVGA_H;
s->fps=10;
s->qmin=3;
}else if (s->maxbr>=128000){
s->vsize.width=MS_VIDEO_SIZE_QCIF_W;
s->vsize.height=MS_VIDEO_SIZE_QCIF_H;
......
......@@ -379,19 +379,18 @@ static void x11video_process(MSFilter *f){
obj->sws1=NULL;
}
if (obj->autofit){
MSVideoSize qvga_size;
MSVideoSize new_window_size;
qvga_size.width=MS_VIDEO_SIZE_QVGA_W;
qvga_size.height=MS_VIDEO_SIZE_QVGA_H;
static const MSVideoSize min_size=MS_VIDEO_SIZE_QVGA;
ms_message("received size is %ix%i",newsize.width,newsize.height);
/*don't resize less than QVGA, it is too small*/
if (ms_video_size_greater_than(qvga_size,newsize)){
new_window_size.width=MS_VIDEO_SIZE_QVGA_W;
new_window_size.height=MS_VIDEO_SIZE_QVGA_H;
if (min_size.width*min_size.height>newsize.width*newsize.height){
new_window_size.width=newsize.width*2;
new_window_size.height=newsize.height*2;
}else new_window_size=newsize;
obj->wsize=new_window_size;
obj->vsize=newsize;
ms_message("autofit: new window size is %ix%i",new_window_size.width,new_window_size.height);
ms_message("autofit: new window size should be %ix%i",new_window_size.width,new_window_size.height);
XResizeWindow(obj->display,obj->window_id,new_window_size.width,new_window_size.height);
XSync(obj->display,FALSE);
x11video_unprepare(f);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment