Commit d92d2653 authored by Simon Morlat's avatar Simon Morlat
Browse files

fix crash with RGB24 top down video format from cameras on windows

fix plenty of warnings on windows.
parent 980ce79d
......@@ -236,6 +236,14 @@ MS2_PUBLIC unsigned int ms_get_cpu_count();
# ifdef HAVE_CONFIG_H
# include "mediastreamer-config.h" /*necessary to know if ENABLE_NLS is there*/
# endif
#ifdef WIN32
#include <malloc.h> //for alloca
#ifdef _MSC_VER
#define alloca _alloca
#endif
#endif
# if defined(ENABLE_NLS)
# include <libintl.h>
# define _(String) dgettext (GETTEXT_PACKAGE, String)
......
......@@ -22,11 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#define alloca _alloca
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
......
......@@ -653,13 +653,13 @@ STDMETHODIMP_(ULONG) DSCapture::AddRef(){
STDMETHODIMP_(ULONG) DSCapture::Release()
{
ms_message("DSCapture::Release");
if ( !InterlockedDecrement( &m_refCount ) ) {
ms_message("DSCapture::Release");
if ( !InterlockedDecrement( &m_refCount ) ) {
int refcnt=m_refCount;
delete this;
return refcnt;
}
return m_refCount;
return m_refCount;
}
static void dummy(void*p){
......@@ -675,8 +675,17 @@ STDMETHODIMP DSCapture::SampleCB( double par1 , IMediaSample * sample)
}
size=sample->GetSize();
//ms_message( "DSCapture::SampleCB pointer=%p, size=%i",p,size);
mblk_t *m=esballoc(p,size,0,dummy);
m->b_wptr+=size;
mblk_t *m;
if (_pixfmt!=MS_RGB24_REV){
m=esballoc(p,size,0,dummy);
m->b_wptr+=size;
}else{
/* make a copy for BGR24 buffers into a new end-padded buffer, because swscale
is doing invalid reads past the end of the original buffers */
m=allocb(size+128,0);
memcpy(m->b_wptr,p,size);
m->b_wptr+=size;
}
ms_mutex_lock(&_mutex);
putq(&_rq,ms_yuv_buf_alloc_from_buffer(_vsize.width,_vsize.height,m));
ms_mutex_unlock(&_mutex);
......@@ -755,6 +764,7 @@ static int find_best_format(ComPtr<IAMStreamConfig> streamConfig, int count,MSVi
int DSCapture::selectBestFormat(ComPtr<IAMStreamConfig> streamConfig, int count){
int index;
_pixfmt=MS_YUV420P;
index=find_best_format(streamConfig, count, &_vsize, _pixfmt);
if (index!=-1) goto success;
......
......@@ -201,9 +201,9 @@ static void player_process(MSFilter *f){
memset(om->b_wptr,0,bytes);
d->pause_time-=f->ticker->interval;
}else{
BOOL res;
err=0;
res = ReadFile(d->fd, om->b_wptr, bytes, &err, NULL) ;
ReadFile(d->fd, om->b_wptr, bytes, &err, NULL) ;
}
if (err>=0){
if (err==bytes){
......@@ -211,7 +211,6 @@ static void player_process(MSFilter *f){
ms_queue_put(f->outputs[0],om);
}
else if (err>0){
BOOL res;
om->b_wptr+=err;
......@@ -236,7 +235,7 @@ static void player_process(MSFilter *f){
{
bytes=bytes-err;
err=0;
res = ReadFile(d->fd, om->b_wptr, bytes, &err, NULL);
ReadFile(d->fd, om->b_wptr, bytes, &err, NULL);
if (err>0){
om->b_wptr+=err;
}
......@@ -245,7 +244,6 @@ static void player_process(MSFilter *f){
ms_queue_put(f->outputs[0],om);
}
else if (err==0){
BOOL res;
ms_filter_notify_no_arg(f,MS_FILE_PLAYER_EOF);
SetFilePointer(d->fd, d->hsize, NULL, FILE_BEGIN);
......@@ -265,7 +263,7 @@ static void player_process(MSFilter *f){
{
bytes=bytes-err;
err=0;
res = ReadFile(d->fd, om->b_wptr, bytes, &err, NULL);
ReadFile(d->fd, om->b_wptr, bytes, &err, NULL);
if (err>0){
om->b_wptr+=err;
ms_queue_put(f->outputs[0],om);
......
......@@ -1670,7 +1670,7 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
uint8_t *jpgbuf;
DWORD err;
HANDLE fd;
BOOL res;
#ifdef UNICODE
WCHAR wUnicode[1024];
MultiByteToWideChar(CP_UTF8, 0, jpgpath, -1, wUnicode, 1024);
......@@ -1704,7 +1704,7 @@ mblk_t *ms_load_jpeg_as_yuv(const char *jpgpath, MSVideoSize *reqsize){
return m;
}
err=0;
res = ReadFile(fd, jpgbuf, st_sizel, &err, NULL) ;
ReadFile(fd, jpgbuf, st_sizel, &err, NULL) ;
if (err!=st_sizel){
ms_error("Could not read as much as wanted !");
......
......@@ -26,9 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msticker.h"
#include <math.h>
#ifdef _MSC_VER
#include <malloc.h>
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
......
......@@ -27,6 +27,7 @@
#include <vpx/vpx_encoder.h>
#include <vpx/vp8cx.h>
#undef interface
#define interface (vpx_codec_vp8_cx())
#define VP8_PAYLOAD_DESC_X_MASK 0x80
......
......@@ -48,6 +48,7 @@ typedef struct WinSndCard{
}WinSndCard;
static void winsndcard_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent){
#if 0
MMRESULT mr = MMSYSERR_NOERROR;
DWORD dwVolume = 0xFFFF;
dwVolume = ((0xFFFF) * percent) / 100;
......@@ -68,6 +69,7 @@ static void winsndcard_set_level(MSSndCard *card, MSSndCardMixerElem e, int perc
default:
ms_warning("winsnd_card_set_level: unsupported command.");
}
#endif
}
static int winsndcard_get_level(MSSndCard *card, MSSndCardMixerElem e){
......
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