Commit 8032fcf2 authored by Simon Morlat's avatar Simon Morlat

optimize pixconv to use YuvBufAllocator

parent b0adfa47
......@@ -28,23 +28,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct PixConvState{
YuvBuf outbuf;
mblk_t *yuv_msg;
MSYuvBufAllocator *allocator;
MSScalerContext *scaler;
MSVideoSize size;
MSPixFmt in_fmt;
MSPixFmt out_fmt;
unsigned long number_of_allocated_yuv_buf;
}PixConvState;
static void pixconv_init(MSFilter *f){
PixConvState *s=ms_new0(PixConvState,1);
s->yuv_msg=NULL;
s->allocator = ms_yuv_buf_allocator_new();
s->size.width = MS_VIDEO_SIZE_CIF_W;
s->size.height = MS_VIDEO_SIZE_CIF_H;
s->in_fmt=MS_YUV420P;
s->out_fmt=MS_YUV420P;
s->scaler=NULL;
s->number_of_allocated_yuv_buf=0;
f->data=s;
}
......@@ -54,28 +52,12 @@ static void pixconv_uninit(MSFilter *f){
ms_scaler_context_free(s->scaler);
s->scaler=NULL;
}
if (s->yuv_msg!=NULL) freemsg(s->yuv_msg);
if (s->number_of_allocated_yuv_buf>1)
ms_warning("Pixconf allocated [%lu] yuv buff",s->number_of_allocated_yuv_buf);
ms_yuv_buf_allocator_free(s->allocator);
ms_free(s);
}
static mblk_t * pixconv_alloc_mblk(PixConvState *s){
if (s->yuv_msg!=NULL){
int ref=s->yuv_msg->b_datap->db_ref;
if (ref==1){
return dupmsg(s->yuv_msg);
}else{
/*the last msg is still referenced by somebody else*/
/*ms_message("Somebody still retaining yuv buffer (ref=%i)",ref);
* seems to be the default situation at least on macosx, removing traces*/
freemsg(s->yuv_msg);
s->yuv_msg=NULL;
}
}
s->yuv_msg=ms_yuv_buf_alloc(&s->outbuf,s->size.width,s->size.height);
s->number_of_allocated_yuv_buf++;
return dupmsg(s->yuv_msg);
return ms_yuv_buf_allocator_get(s->allocator, &s->outbuf, s->size.width,s->size.height);
}
static void pixconv_process(MSFilter *f){
......
......@@ -337,7 +337,7 @@ static int v4m_start(MSFilter *f, void *arg) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
v4mState *s = (v4mState*)f->data;
[s->webcam performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO];
ms_message("v4m video device opened.");
ms_message("qtcapture video device opened.");
[myPool drain];
return 0;
}
......@@ -346,7 +346,7 @@ static int v4m_stop(MSFilter *f, void *arg) {
NSAutoreleasePool* myPool = [[NSAutoreleasePool alloc] init];
v4mState *s = (v4mState*)f->data;
[s->webcam performSelectorOnMainThread:@selector(stop) withObject:nil waitUntilDone:NO];
ms_message("v4m video device closed.");
ms_message("qtcapture video device closed.");
[myPool drain];
return 0;
}
......@@ -461,7 +461,7 @@ static MSFilterMethod methods[] = {
MSFilterDesc ms_v4m_desc={
.id=MS_V4L_ID,
.name="MSV4m",
.name="MSQtCapture",
.text="A video for macosx compatible source filter to stream pictures.",
.ninputs=0,
.noutputs=1,
......
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