[Redbutton-devel] SF.net SVN: redbutton: [77] redbutton-browser/trunk
Brought to you by:
skilvington
From: <ski...@us...> - 2006-05-22 16:24:15
|
Revision: 77 Author: skilvington Date: 2006-05-22 09:24:08 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=77&view=rev Log Message: ----------- implement ScaleVideo Modified Paths: -------------- redbutton-browser/trunk/MHEGStreamPlayer.c redbutton-browser/trunk/VideoClass.c redbutton-browser/trunk/add_instance_vars.conf Modified: redbutton-browser/trunk/MHEGStreamPlayer.c =================================================================== --- redbutton-browser/trunk/MHEGStreamPlayer.c 2006-05-22 16:03:57 UTC (rev 76) +++ redbutton-browser/trunk/MHEGStreamPlayer.c 2006-05-22 16:24:08 UTC (rev 77) @@ -400,11 +400,19 @@ if(!drop_frame) { /* scale the next frame if necessary */ - out_width = vf->width; - out_height = vf->height; -/* TODO */ -/* use scaled values if ScaleVideo has been called */ -/* have a lock incase we are doing ScaleVideo in another thread */ + pthread_mutex_lock(&p->video->inst.scaled_lock); + /* use scaled values if ScaleVideo has been called */ + if(p->video->inst.scaled) + { + out_width = p->video->inst.scaled_width; + out_height = p->video->inst.scaled_height; + } + else + { + out_width = vf->width; + out_height = vf->height; + } + pthread_mutex_unlock(&p->video->inst.scaled_lock); /* scale up if fullscreen */ if(d->fullscreen) { @@ -435,9 +443,10 @@ //now=av_gettime(); //printf("display frame %d: pts=%f this_time=%lld real_time=%lld (diff=%lld)\n", nframes, vf->pts, last_time, now, now-last_time); /* origin of VideoClass */ -/* TODO should probably have a lock for this in case we are doing SetPosition in another thread */ + pthread_mutex_lock(&p->video->inst.bbox_lock); out_x = p->video->inst.Position.x_position; out_y = p->video->inst.Position.y_position; + pthread_mutex_unlock(&p->video->inst.bbox_lock); /* scale if fullscreen */ if(d->fullscreen) { @@ -447,7 +456,9 @@ /* draw the current frame */ MHEGVideoOutput_drawFrame(&vo, out_x, out_y); /* redraw objects above the video */ + pthread_mutex_lock(&p->video->inst.bbox_lock); MHEGDisplay_refresh(d, &p->video->inst.Position, &p->video->inst.BoxSize); + pthread_mutex_unlock(&p->video->inst.bbox_lock); /* get it drawn straight away */ XFlush(d->dpy); } Modified: redbutton-browser/trunk/VideoClass.c =================================================================== --- redbutton-browser/trunk/VideoClass.c 2006-05-22 16:03:57 UTC (rev 76) +++ redbutton-browser/trunk/VideoClass.c 2006-05-22 16:24:08 UTC (rev 77) @@ -30,6 +30,10 @@ v->VideoDecodeOffset.x_position = 0; v->VideoDecodeOffset.y_position = 0; + pthread_mutex_init(&v->bbox_lock, NULL); + pthread_mutex_init(&v->scaled_lock, NULL); + v->scaled = false; + return; } @@ -39,6 +43,9 @@ if(v->have_PaletteRef) free_ObjectReference(&v->PaletteRef); + pthread_mutex_destroy(&v->bbox_lock); + pthread_mutex_destroy(&v->scaled_lock); + return; } @@ -137,8 +144,10 @@ old.x_position = t->inst.Position.x_position; old.y_position = t->inst.Position.y_position; + pthread_mutex_lock(&t->inst.bbox_lock); t->inst.Position.x_position = GenericInteger_getInteger(¶ms->new_x_position, caller_gid); t->inst.Position.y_position = GenericInteger_getInteger(¶ms->new_y_position, caller_gid); + pthread_mutex_unlock(&t->inst.bbox_lock); /* if it is active, redraw it */ if(t->rootClass.inst.RunningStatus) @@ -196,8 +205,10 @@ old.x_length = t->inst.BoxSize.x_length; old.y_length = t->inst.BoxSize.y_length; + pthread_mutex_lock(&t->inst.bbox_lock); t->inst.BoxSize.x_length = GenericInteger_getInteger(¶ms->x_new_box_size, caller_gid); t->inst.BoxSize.y_length = GenericInteger_getInteger(¶ms->y_new_box_size, caller_gid); + pthread_mutex_unlock(&t->inst.bbox_lock); /* if it is active, redraw it */ if(t->rootClass.inst.RunningStatus) @@ -346,16 +357,14 @@ void VideoClass_ScaleVideo(VideoClass *t, ScaleVideo *params, OctetString *caller_gid) { - int x_scale; - int y_scale; - verbose("VideoClass: %s; ScaleVideo", ExternalReference_name(&t->rootClass.inst.ref)); - x_scale = GenericInteger_getInteger(¶ms->x_scale, caller_gid); - y_scale = GenericInteger_getInteger(¶ms->y_scale, caller_gid); + pthread_mutex_lock(&t->inst.scaled_lock); + t->inst.scaled = true; + t->inst.scaled_width = GenericInteger_getInteger(¶ms->x_scale, caller_gid); + t->inst.scaled_height = GenericInteger_getInteger(¶ms->y_scale, caller_gid); + pthread_mutex_unlock(&t->inst.scaled_lock); -/* TODO */ -printf("TODO: VideoClass_ScaleVideo(%d, %d) not yet implemented\n", x_scale, y_scale); return; } Modified: redbutton-browser/trunk/add_instance_vars.conf =================================================================== --- redbutton-browser/trunk/add_instance_vars.conf 2006-05-22 16:03:57 UTC (rev 76) +++ redbutton-browser/trunk/add_instance_vars.conf 2006-05-22 16:24:08 UTC (rev 77) @@ -165,6 +165,8 @@ </TextClass> <VideoClass> +#include <pthread.h> + typedef struct { /* inherited from VisibleClass */ @@ -175,6 +177,13 @@ /* VideoClass */ /* UK MHEG Profile adds this */ XYPosition VideoDecodeOffset; + /* we add a lock for the size/position */ + pthread_mutex_t bbox_lock; + /* and the scaled size */ + pthread_mutex_t scaled_lock; + bool scaled; + unsigned int scaled_width; + unsigned int scaled_height; } VideoClassInstanceVars; </VideoClass> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |