[xiph-cvs] cvs commit: theora/win32/experimental/splayer splayer.c
Mauricio Piacentini
mauricio at xiph.org
Sun Jun 8 18:30:58 PDT 2003
mauricio 03/06/08 21:30:58
Modified: examples player_example.c
win32/experimental/splayer splayer.c
Log:
Player examples updated to display the encoded frame rect only, respecting the offsets specified in the header. this was a pending item for alpha2
Revision Changes Path
1.19 +22 -18 theora/examples/player_example.c
Index: player_example.c
===================================================================
RCS file: /usr/local/cvsroot/theora/examples/player_example.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- player_example.c 8 Jun 2003 00:08:38 -0000 1.18
+++ player_example.c 9 Jun 2003 01:30:58 -0000 1.19
@@ -12,7 +12,7 @@
function: example SDL player application; plays Ogg Theora files (with
optional Vorbis audio second stream)
- last mod: $Id: player_example.c,v 1.18 2003/06/08 00:08:38 giles Exp $
+ last mod: $Id: player_example.c,v 1.19 2003/06/09 01:30:58 mauricio Exp $
********************************************************************/
@@ -294,14 +294,14 @@
exit(1);
}
- screen = SDL_SetVideoMode(ti.width, ti.height, 0, SDL_SWSURFACE);
+ screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
if ( screen == NULL ) {
fprintf(stderr, "Unable to set %dx%d video: %s\n",
- ti.width,ti.height,SDL_GetError());
+ ti.frame_width,ti.frame_height,SDL_GetError());
exit(1);
}
- yuv_overlay = SDL_CreateYUVOverlay(ti.width, ti.height,
+ yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
SDL_YV12_OVERLAY,
screen);
if ( yuv_overlay == NULL ) {
@@ -311,8 +311,8 @@
}
rect.x = 0;
rect.y = 0;
- rect.w = ti.width;
- rect.h = ti.height;
+ rect.w = ti.frame_width;
+ rect.h = ti.frame_height;
SDL_DisplayYUVOverlay(yuv_overlay, &rect);
}
@@ -320,8 +320,9 @@
static void video_write(void){
int i;
yuv_buffer yuv;
+ int crop_offset;
theora_decode_YUVout(&td,&yuv);
-
+
/* Lock SDL_yuv_overlay */
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) < 0 ) return;
@@ -331,17 +332,20 @@
/* let's draw the data (*yuv[3]) on a SDL screen (*screen) */
/* deal with border stride */
/* reverse u and v for SDL */
- for(i=0;i<yuv.y_height;i++)
- memcpy(yuv_overlay->pixels[0]+yuv.y_width*i,
- yuv.y+yuv.y_stride*i,
- yuv.y_width);
- for(i=0;i<yuv.uv_height;i++){
- memcpy(yuv_overlay->pixels[1]+yuv.uv_width*i,
- yuv.v+yuv.uv_stride*i,
- yuv.uv_width);
- memcpy(yuv_overlay->pixels[2]+yuv.uv_width*i,
- yuv.u+yuv.uv_stride*i,
- yuv.uv_width);
+ /* and crop input properly, respecting the encoded frame rect */
+ crop_offset=ti.offset_x+yuv.y_stride*ti.offset_y;
+ for(i=0;i<yuv_overlay->h;i++)
+ memcpy(yuv_overlay->pixels[0]+yuv_overlay->w*i,
+ yuv.y+crop_offset+yuv.y_stride*i,
+ yuv_overlay->w);
+ crop_offset=(ti.offset_x/2)+(yuv.uv_stride)*(ti.offset_y/2);
+ for(i=0;i<yuv_overlay->h/2;i++){
+ memcpy(yuv_overlay->pixels[1]+yuv_overlay->w/2*i,
+ yuv.v+crop_offset+yuv.uv_stride*i,
+ yuv_overlay->w/2);
+ memcpy(yuv_overlay->pixels[2]+yuv_overlay->w/2*i,
+ yuv.u+crop_offset+yuv.uv_stride*i,
+ yuv_overlay->w/2);
}
/* Unlock SDL_yuv_overlay */
<p><p>1.5 +21 -17 theora/win32/experimental/splayer/splayer.c
Index: splayer.c
===================================================================
RCS file: /usr/local/cvsroot/theora/win32/experimental/splayer/splayer.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- splayer.c 8 Jun 2003 00:08:40 -0000 1.4
+++ splayer.c 9 Jun 2003 01:30:58 -0000 1.5
@@ -186,14 +186,14 @@
exit(1);
}
- screen = SDL_SetVideoMode(ti.width, ti.height, 0, SDL_SWSURFACE);
+ screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
if ( screen == NULL ) {
printf("Unable to set %dx%d video: %s\n",
- ti.width,ti.height,SDL_GetError());
+ ti.frame_width,ti.frame_height,SDL_GetError());
exit(1);
}
- yuv_overlay = SDL_CreateYUVOverlay(ti.width, ti.height,
+ yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
SDL_YV12_OVERLAY,
screen);
if ( yuv_overlay == NULL ) {
@@ -203,8 +203,8 @@
}
rect.x = 0;
rect.y = 0;
- rect.w = ti.width;
- rect.h = ti.height;
+ rect.w = ti.frame_width;
+ rect.h = ti.frame_height;
SDL_DisplayYUVOverlay(yuv_overlay, &rect);
}
@@ -213,8 +213,9 @@
/*taken from player_sample.c test file for theora alpha*/
int i;
yuv_buffer yuv;
+ int crop_offset;
theora_decode_YUVout(&td,&yuv);
-
+
/* Lock SDL_yuv_overlay */
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) < 0 ) return;
@@ -224,17 +225,20 @@
/* let's draw the data (*yuv[3]) on a SDL screen (*screen) */
/* deal with border stride */
/* reverse u and v for SDL */
- for(i=0;i<yuv.y_height;i++)
- memcpy(yuv_overlay->pixels[0]+yuv.y_width*i,
- yuv.y+yuv.y_stride*i,
- yuv.y_width);
- for(i=0;i<yuv.uv_height;i++){
- memcpy(yuv_overlay->pixels[1]+yuv.uv_width*i,
- yuv.v+yuv.uv_stride*i,
- yuv.uv_width);
- memcpy(yuv_overlay->pixels[2]+yuv.uv_width*i,
- yuv.u+yuv.uv_stride*i,
- yuv.uv_width);
+ /* and crop input properly, respecting the encoded frame rect */
+ crop_offset=ti.offset_x+yuv.y_stride*ti.offset_y;
+ for(i=0;i<yuv_overlay->h;i++)
+ memcpy(yuv_overlay->pixels[0]+yuv_overlay->w*i,
+ yuv.y+crop_offset+yuv.y_stride*i,
+ yuv_overlay->w);
+ crop_offset=(ti.offset_x/2)+(yuv.uv_stride)*(ti.offset_y/2);
+ for(i=0;i<yuv_overlay->h/2;i++){
+ memcpy(yuv_overlay->pixels[1]+yuv_overlay->w/2*i,
+ yuv.v+crop_offset+yuv.uv_stride*i,
+ yuv_overlay->w/2);
+ memcpy(yuv_overlay->pixels[2]+yuv_overlay->w/2*i,
+ yuv.u+crop_offset+yuv.uv_stride*i,
+ yuv_overlay->w/2);
}
/* Unlock SDL_yuv_overlay */
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list