[xiph-commits] r7694 - in experimental/derf/theora-exp: examples
include/theora lib
tterribe at motherfish-iii.xiph.org
tterribe at motherfish-iii.xiph.org
Fri Sep 3 17:36:29 PDT 2004
Author: tterribe
Date: 2004-09-03 17:36:28 -0700 (Fri, 03 Sep 2004)
New Revision: 7694
Modified:
experimental/derf/theora-exp/examples/dump_video.c
experimental/derf/theora-exp/examples/encoder_example.c
experimental/derf/theora-exp/examples/player_example.c
experimental/derf/theora-exp/include/theora/theora.h
experimental/derf/theora-exp/lib/decinfo.c
experimental/derf/theora-exp/lib/decode.c
experimental/derf/theora-exp/lib/encinfo.c
experimental/derf/theora-exp/lib/encode.c
experimental/derf/theora-exp/lib/impmap.c
experimental/derf/theora-exp/lib/state.c
Log:
Replace width and height with frame_width and frame_height and replace
frame_width, frame_height, offset_x, and offset_y with pic_width, pic_height,
pic_x, and pic_y to conform to the notation in the spec.
This completes the metaphor of an enlarged "frame" around a "picture"
containing the actual content, which I find much more intuitively appealing.
Modified: experimental/derf/theora-exp/examples/dump_video.c
===================================================================
--- experimental/derf/theora-exp/examples/dump_video.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/examples/dump_video.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -252,8 +252,9 @@
if(theora_p){
td=theora_decode_alloc(&ti,ts);
fprintf(stderr,"Ogg logical stream %x is Theora %dx%d %.02f fps video\nEncoded frame content is %dx%d with %dx%d offset\n",
- to.serialno,ti.width,ti.height, (double)ti.fps_numerator/ti.fps_denominator,
- ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
+ to.serialno,ti.frame_width,ti.frame_height,
+ (double)ti.fps_numerator/ti.fps_denominator,
+ ti.pic_width, ti.pic_height, ti.pic_x, ti.pic_y);
}else{
/* tear down the partial theora setup */
theora_info_clear(&ti);
Modified: experimental/derf/theora-exp/examples/encoder_example.c
===================================================================
--- experimental/derf/theora-exp/examples/encoder_example.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/examples/encoder_example.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -17,7 +17,9 @@
********************************************************************/
#define _GNU_SOURCE
+#if !defined(_REENTRANT)
#define _REENTRANT
+#endif
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
@@ -72,12 +74,12 @@
float audio_q=.1F;
int audio_r=-1;
-int video_x=0;
-int video_y=0;
-int frame_x=0;
-int frame_y=0;
-int frame_x_offset=0;
-int frame_y_offset=0;
+int frame_w=0;
+int frame_h=0;
+int pic_w=0;
+int pic_h=0;
+int pic_x=0;
+int pic_y=0;
int video_hzn=-1;
int video_hzd=-1;
int video_an=-1;
@@ -241,7 +243,7 @@
}
ret=sscanf((char *)buffer,"MPEG2 W%d H%d F%d:%d I%c A%d:%d",
- &frame_x,&frame_y,&tmp_video_hzn,&tmp_video_hzd,&interlace,
+ &pic_w,&pic_h,&tmp_video_hzn,&tmp_video_hzd,&interlace,
&tmp_video_an,&tmp_video_ad);
if(ret<7){
fprintf(stderr,"Error parsing YUV4MPEG2 header in file %s.\n",f);
@@ -262,7 +264,7 @@
video=test;
fprintf(stderr,"File %s is %dx%d %.02f fps YUV12 video.\n",
- f,frame_x,frame_y,(double)video_hzn/video_hzd);
+ f,pic_w,pic_h,(double)video_hzn/video_hzd);
return;
}
@@ -364,19 +366,19 @@
if(state==-1){
/* initialize the double frame buffer */
- yuvframe[0]=malloc(video_x*video_y*3/2);
- yuvframe[1]=malloc(video_x*video_y*3/2);
+ yuvframe[0]=malloc(frame_w*frame_h*3/2);
+ yuvframe[1]=malloc(frame_w*frame_h*3/2);
/* clear initial frame as it may be larger than actual video data */
/* fill Y plane with 0x10 and UV planes with 0X80, for black data */
- memset(yuvframe[0],0x10,video_x*video_y);
- memset(yuvframe[0]+video_x*video_y,0x80,video_x*video_y/2);
- memset(yuvframe[1],0x10,video_x*video_y);
- memset(yuvframe[1]+video_x*video_y,0x80,video_x*video_y/2);
+ memset(yuvframe[0],0x10,frame_w*frame_h);
+ memset(yuvframe[0]+frame_w*frame_h,0x80,frame_w*frame_h/2);
+ memset(yuvframe[1],0x10,frame_w*frame_h);
+ memset(yuvframe[1]+frame_w*frame_h,0x80,frame_w*frame_h/2);
#if defined(OC_444_MODE)
- upsamp_uvdata=malloc(2*video_x*video_y);
+ upsamp_uvdata=malloc(2*frame_w*frame_h);
#elif defined(OC_422_MODE)
- upsamp_uvdata=malloc(video_x*video_y);
+ upsamp_uvdata=malloc(frame_w*frame_h);
#endif
state=0;
@@ -421,27 +423,27 @@
}
/* read the Y plane into our frame buffer with centering */
- line=yuvframe[i]+video_x*frame_y_offset+frame_x_offset;
- for(e=0;e<frame_y;e++){
- ret=fread(line,1,frame_x,video);
- if(ret!=frame_x) break;
- line+=video_x;
+ line=yuvframe[i]+frame_w*pic_y+pic_x;
+ for(e=0;e<pic_h;e++){
+ ret=fread(line,1,pic_w,video);
+ if(ret!=pic_w) break;
+ line+=frame_w;
}
/* now get Cb plane*/
- line=yuvframe[i]+(video_x*video_y)
- +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
- for(e=0;e<frame_y/2;e++){
- ret=fread(line,1,frame_x/2,video);
- if(ret!=frame_x/2) break;
- line+=video_x/2;
+ line=yuvframe[i]+(frame_w*frame_h)
+ +(frame_w/2)*(pic_y/2)+pic_x/2;
+ for(e=0;e<pic_h/2;e++){
+ ret=fread(line,1,pic_w/2,video);
+ if(ret!=pic_w/2) break;
+ line+=frame_w/2;
}
/* and the Cr plane*/
- line=yuvframe[i]+(video_x*video_y*5/4)
- +(video_x/2)*(frame_y_offset/2)+frame_x_offset/2;
- for(e=0;e<frame_y/2;e++){
- ret=fread(line,1,frame_x/2,video);
- if(ret!=frame_x/2) break;
- line+=video_x/2;
+ line=yuvframe[i]+(frame_w*frame_h*5/4)
+ +(frame_w/2)*(pic_y/2)+pic_x/2;
+ for(e=0;e<pic_h/2;e++){
+ ret=fread(line,1,pic_w/2,video);
+ if(ret!=pic_w/2) break;
+ line+=frame_w/2;
}
state++;
}
@@ -455,138 +457,138 @@
/* Theora is a one-frame-in,one-frame-out system; submit a frame
for compression and pull out the packet */
- ycbcr[0].width=video_x;
- ycbcr[0].height=video_y;
- ycbcr[0].ystride=video_x;
+ ycbcr[0].width=frame_w;
+ ycbcr[0].height=frame_h;
+ ycbcr[0].ystride=frame_w;
ycbcr[0].data=yuvframe[0];
#if defined(OC_444_MODE)
{
- int cboffset=video_x*video_y;
- int croffset=cboffset+(video_x/2)*(video_y/2);
+ int cboffset=frame_w*frame_h;
+ int croffset=cboffset+(frame_w/2)*(frame_h/2);
int f;
- ycbcr[1].width=video_x;
- ycbcr[1].height=video_y;
- ycbcr[1].ystride=video_x;
+ ycbcr[1].width=frame_w;
+ ycbcr[1].height=frame_h;
+ ycbcr[1].ystride=frame_w;
ycbcr[1].data=upsamp_uvdata;
- for(e=0;e<video_y/2;e++){
- for(f=0;f<video_x/2;f++){
- if(e+1<video_y/2){
- if(f+1<video_x/2){
- ycbcr[1].data[e*2*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[e*2*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+e*(video_x/2)+f+1]+1>>1);
- ycbcr[1].data[(e*2+1)*video_x+f*2]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f]+1>>1);
- ycbcr[1].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+e*(video_x/2)+f+1]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f+1]+2>>2);
+ for(e=0;e<frame_h/2;e++){
+ for(f=0;f<frame_w/2;f++){
+ if(e+1<frame_h/2){
+ if(f+1<frame_w/2){
+ ycbcr[1].data[e*2*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[e*2*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+e*(frame_w/2)+f+1]+1>>1);
+ ycbcr[1].data[(e*2+1)*frame_w+f*2]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f]+1>>1);
+ ycbcr[1].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+e*(frame_w/2)+f+1]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f+1]+2>>2);
}
else{
- ycbcr[1].data[e*2*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[e*2*video_x+f*2+1]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*video_x+f*2]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f]+1>>1);
- ycbcr[1].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f]+1>>1);
+ ycbcr[1].data[e*2*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[e*2*frame_w+f*2+1]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*frame_w+f*2]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f]+1>>1);
+ ycbcr[1].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f]+1>>1);
}
}
else{
- if(f+1<video_x/2){
- ycbcr[1].data[e*2*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[e*2*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+e*(video_x/2)+f+1]+1>>1);
- ycbcr[1].data[(e*2+1)*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+e*(video_x/2)+f+1]+1>>1);
+ if(f+1<frame_w/2){
+ ycbcr[1].data[e*2*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[e*2*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+e*(frame_w/2)+f+1]+1>>1);
+ ycbcr[1].data[(e*2+1)*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+e*(frame_w/2)+f+1]+1>>1);
}
else{
- ycbcr[1].data[e*2*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[e*2*video_x+f*2+1]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*video_x+f*2]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*video_x+f*2+1]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
+ ycbcr[1].data[e*2*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[e*2*frame_w+f*2+1]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*frame_w+f*2]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*frame_w+f*2+1]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
}
}
}
}
- ycbcr[2].width=video_x;
- ycbcr[2].height=video_y;
- ycbcr[2].ystride=video_x;
- ycbcr[2].data=upsamp_uvdata+video_x*video_y;
+ ycbcr[2].width=frame_w;
+ ycbcr[2].height=frame_h;
+ ycbcr[2].ystride=frame_w;
+ ycbcr[2].data=upsamp_uvdata+frame_w*frame_h;
- for(e=0;e<video_y/2;e++){
- for(f=0;f<video_x/2;f++){
- if(e+1<video_y/2){
- if(f+1<video_x/2){
- ycbcr[2].data[e*2*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[e*2*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+e*(video_x/2)+f+1]+1>>1);
- ycbcr[2].data[(e*2+1)*video_x+f*2]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f]+1>>1);
- ycbcr[2].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+e*(video_x/2)+f+1]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f+1]+2>>2);
+ for(e=0;e<frame_h/2;e++){
+ for(f=0;f<frame_w/2;f++){
+ if(e+1<frame_h/2){
+ if(f+1<frame_w/2){
+ ycbcr[2].data[e*2*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[e*2*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+e*(frame_w/2)+f+1]+1>>1);
+ ycbcr[2].data[(e*2+1)*frame_w+f*2]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f]+1>>1);
+ ycbcr[2].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+e*(frame_w/2)+f+1]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f+1]+2>>2);
}
else{
- ycbcr[2].data[e*2*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[e*2*video_x+f*2+1]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*video_x+f*2]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f]+1>>1);
- ycbcr[2].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f]+1>>1);
+ ycbcr[2].data[e*2*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[e*2*frame_w+f*2+1]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*frame_w+f*2]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f]+1>>1);
+ ycbcr[2].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f]+1>>1);
}
}
else{
- if(f+1<video_x/2){
- ycbcr[2].data[e*2*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[e*2*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+e*(video_x/2)+f+1]+1>>1);
- ycbcr[2].data[(e*2+1)*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*video_x+f*2+1]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+e*(video_x/2)+f+1]+1>>1);
+ if(f+1<frame_w/2){
+ ycbcr[2].data[e*2*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[e*2*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+e*(frame_w/2)+f+1]+1>>1);
+ ycbcr[2].data[(e*2+1)*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*frame_w+f*2+1]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+e*(frame_w/2)+f+1]+1>>1);
}
else{
- ycbcr[2].data[e*2*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[e*2*video_x+f*2+1]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*video_x+f*2]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*video_x+f*2+1]=
- yuvframe[0][croffset+e*(video_x/2)+f];
+ ycbcr[2].data[e*2*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[e*2*frame_w+f*2+1]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*frame_w+f*2]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*frame_w+f*2+1]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
}
}
}
@@ -594,66 +596,66 @@
}
#elif defined(OC_422_MODE)
{
- int cboffset=video_x*video_y;
- int croffset=cboffset+(video_x/2)*(video_y/2);
+ int cboffset=frame_w*frame_h;
+ int croffset=cboffset+(frame_w/2)*(frame_h/2);
int f;
- ycbcr[1].width=video_x/2;
- ycbcr[1].height=video_y;
- ycbcr[1].ystride=video_x/2;
+ ycbcr[1].width=frame_w/2;
+ ycbcr[1].height=frame_h;
+ ycbcr[1].ystride=frame_w/2;
ycbcr[1].data=upsamp_uvdata;
- for(e=0;e<video_y/2;e++){
- for(f=0;f<video_x/2;f++){
- if(e+1<video_y/2){
- ycbcr[1].data[e*2*(video_x/2)+f]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*(video_x/2)+f]=(unsigned char)
- (yuvframe[0][cboffset+e*(video_x/2)+f]+
- yuvframe[0][cboffset+(e+1)*(video_x/2)+f]+1>>1);
+ for(e=0;e<frame_h/2;e++){
+ for(f=0;f<frame_w/2;f++){
+ if(e+1<frame_h/2){
+ ycbcr[1].data[e*2*(frame_w/2)+f]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*(frame_w/2)+f]=(unsigned char)
+ (yuvframe[0][cboffset+e*(frame_w/2)+f]+
+ yuvframe[0][cboffset+(e+1)*(frame_w/2)+f]+1>>1);
}
else{
- ycbcr[1].data[e*2*(video_x/2)+f]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
- ycbcr[1].data[(e*2+1)*(video_x/2)+f]=
- yuvframe[0][cboffset+e*(video_x/2)+f];
+ ycbcr[1].data[e*2*(frame_w/2)+f]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
+ ycbcr[1].data[(e*2+1)*(frame_w/2)+f]=
+ yuvframe[0][cboffset+e*(frame_w/2)+f];
}
}
}
- ycbcr[2].width=video_x/2;
- ycbcr[2].height=video_y;
- ycbcr[2].ystride=video_x/2;
- ycbcr[2].data=upsamp_uvdata+video_y*(video_x/2);
+ ycbcr[2].width=frame_w/2;
+ ycbcr[2].height=frame_h;
+ ycbcr[2].ystride=frame_w/2;
+ ycbcr[2].data=upsamp_uvdata+frame_h*(frame_w/2);
- for(e=0;e<video_y/2;e++){
- for(f=0;f<video_x/2;f++){
- if(e+1<video_y/2){
- ycbcr[2].data[e*2*(video_x/2)+f]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*(video_x/2)+f]=(unsigned char)
- (yuvframe[0][croffset+e*(video_x/2)+f]+
- yuvframe[0][croffset+(e+1)*(video_x/2)+f]+1>>1);
+ for(e=0;e<frame_h/2;e++){
+ for(f=0;f<frame_w/2;f++){
+ if(e+1<frame_h/2){
+ ycbcr[2].data[e*2*(frame_w/2)+f]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*(frame_w/2)+f]=(unsigned char)
+ (yuvframe[0][croffset+e*(frame_w/2)+f]+
+ yuvframe[0][croffset+(e+1)*(frame_w/2)+f]+1>>1);
}
else{
- ycbcr[2].data[e*2*(video_x/2)+f]=
- yuvframe[0][croffset+e*(video_x/2)+f];
- ycbcr[2].data[(e*2+1)*(video_x/2)+f]=
- yuvframe[0][croffset+e*(video_x/2)+f];
+ ycbcr[2].data[e*2*(frame_w/2)+f]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
+ ycbcr[2].data[(e*2+1)*(frame_w/2)+f]=
+ yuvframe[0][croffset+e*(frame_w/2)+f];
}
}
}
}
#else
- ycbcr[1].width=video_x/2;
- ycbcr[1].height=video_y/2;
- ycbcr[1].ystride=video_x/2;
- ycbcr[1].data=yuvframe[0]+video_x*video_y;
+ ycbcr[1].width=frame_w/2;
+ ycbcr[1].height=frame_h/2;
+ ycbcr[1].ystride=frame_w/2;
+ ycbcr[1].data=yuvframe[0]+frame_w*frame_h;
- ycbcr[2].width=video_x/2;
- ycbcr[2].height=video_y/2;
- ycbcr[2].ystride=video_x/2;
- ycbcr[2].data=yuvframe[0]+video_x*video_y*5/4;
+ ycbcr[2].width=frame_w/2;
+ ycbcr[2].height=frame_h/2;
+ ycbcr[2].ystride=frame_w/2;
+ ycbcr[2].data=yuvframe[0]+frame_w*frame_h*5/4;
#endif
theora_encode_ycbcr_in(td,ycbcr);
@@ -799,20 +801,20 @@
fprintf(stderr,"No video files submitted for compression?\n");
exit(1);
}
- /* Theora has a divisible-by-sixteen restriction for the encoded video size */
- /* scale the frame size up to the nearest /16 and calculate offsets */
- video_x=((frame_x + 15) >>4)<<4;
- video_y=((frame_y + 15) >>4)<<4;
- frame_x_offset=(video_x-frame_x)/2;
- frame_y_offset=(video_y-frame_y)/2;
+ /* Theora has a divisible-by-sixteen restriction for the encoded frame size */
+ /* scale the picture size up to the nearest /16 and calculate offsets */
+ frame_w=pic_w+15&~0xF;
+ frame_h=pic_h+15&~0xF;
+ pic_x=frame_w-pic_w>>1&~1;
+ pic_y=frame_h-pic_h>>1&~1;
theora_info_init(&ti);
- ti.width=video_x;
- ti.height=video_y;
- ti.frame_width=frame_x;
- ti.frame_height=frame_y;
- ti.offset_x=frame_x_offset;
- ti.offset_y=frame_y_offset;
+ ti.frame_width=frame_w;
+ ti.frame_height=frame_h;
+ ti.pic_width=pic_w;
+ ti.pic_height=pic_h;
+ ti.pic_x=pic_x;
+ ti.pic_y=pic_y;
ti.fps_numerator=video_hzn;
ti.fps_denominator=video_hzd;
ti.aspect_numerator=video_an;
Modified: experimental/derf/theora-exp/examples/player_example.c
===================================================================
--- experimental/derf/theora-exp/examples/player_example.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/examples/player_example.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -303,14 +303,14 @@
exit(1);
}
- screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
+ screen = SDL_SetVideoMode(ti.pic_width, ti.pic_height, 0, SDL_SWSURFACE);
if ( screen == NULL ) {
fprintf(stderr, "Unable to set %dx%d video: %s\n",
- ti.frame_width,ti.frame_height,SDL_GetError());
+ ti.pic_width,ti.pic_height,SDL_GetError());
exit(1);
}
- yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
+ yuv_overlay = SDL_CreateYUVOverlay(ti.pic_width, ti.pic_height,
SDL_YV12_OVERLAY,
screen);
if ( yuv_overlay == NULL ) {
@@ -320,8 +320,8 @@
}
rect.x = 0;
rect.y = 0;
- rect.w = ti.frame_width;
- rect.h = ti.frame_height;
+ rect.w = ti.pic_width;
+ rect.h = ti.pic_height;
SDL_DisplayYUVOverlay(yuv_overlay, &rect);
}
@@ -349,9 +349,9 @@
for (pli = 0; pli < 3; pli++) {
wscale = ycbcr[0].width / ycbcr[pli].width;
hscale = ycbcr[0].height / ycbcr[pli].height;
- crop_offset = (ti.offset_x / wscale)
+ crop_offset = (ti.pic_x / wscale)
+ (ycbcr[pli].ystride)
- * (ti.offset_y / hscale);
+ * (ti.pic_y / hscale);
for(i=0;i<yuv_overlay->h / hscale;i++)
memcpy(yuv_overlay->pixels[planemap[pli]]
+ yuv_overlay->pitches[planemap[pli]]*i,
@@ -570,11 +570,11 @@
if(theora_p){
td=theora_decode_alloc(&ti,ts);
printf("Ogg logical stream %x is Theora %dx%d %.02f fps video\n",
- to.serialno,ti.width,ti.height,
+ to.serialno,ti.frame_width,ti.frame_height,
(double)ti.fps_numerator/ti.fps_denominator);
- if(ti.width!=ti.frame_width || ti.height!=ti.frame_height)
+ if(ti.frame_width!=ti.pic_width || ti.frame_height!=ti.pic_height)
printf(" Frame content is %dx%d with offset (%d,%d).\n",
- ti.frame_width, ti.frame_height, ti.offset_x, ti.offset_y);
+ ti.pic_width, ti.pic_height, ti.pic_x, ti.pic_y);
report_colorspace(&ti);
dump_comments(&tc);
theora_decoder_ctl(td,OC_DECCTL_GET_PPLEVEL_MAX,&pp_level_max,
Modified: experimental/derf/theora-exp/include/theora/theora.h
===================================================================
--- experimental/derf/theora-exp/include/theora/theora.h 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/include/theora/theora.h 2004-09-04 00:36:28 UTC (rev 7694)
@@ -172,21 +172,24 @@
unsigned char version_major;
unsigned char version_minor;
unsigned char version_subminor;
- /*The encoded width: must be a multiple of 16, and less than 1048576.*/
- ogg_uint32_t width;
- /*The encoded height: must be a multiple of 16, and less than 1048576.*/
- ogg_uint32_t height;
- /*The displayed width: must be no larger than width.*/
+ /*The encoded frame width: must be a multiple of 16, and less than 1048576.*/
ogg_uint32_t frame_width;
- /*The displayed height: must be no larger than height.*/
+ /*The encoded frame height: must be a multiple of 16, and less than
+ 1048576.*/
ogg_uint32_t frame_height;
- /*The x offset of the displayed frame: must be no larger than
- width-frame_width or 255, whichever is smaller.*/
- ogg_uint32_t offset_x;
- /*The y offset of the displayed frame: must be no larger than
- height-frame_height, and height-frame_height-offset_y must be no larger
- than 255.*/
- ogg_uint32_t offset_y;
+ /*The displayed picture width: must be no larger than width.*/
+ ogg_uint32_t pic_width;
+ /*The displayed picture height: must be no larger than height.*/
+ ogg_uint32_t pic_height;
+ /*The x offset of the displayed picture: must be no larger than
+ frame_width-pic_width or 255, whichever is smaller.*/
+ ogg_uint32_t pic_x;
+ /*The y offset of the displayed picture: must be no larger than
+ frame_height-pic_height, and frame_height-pic_height-pic_y must be no
+ larger than 255.
+ This offset is specified from the top of the image, as this API uses the
+ standard graphics left-handed coordinate system.*/
+ ogg_uint32_t pic_y;
/*The frame rate, as a fraction.
If either is 0, the frame rate is undefined.*/
ogg_uint32_t fps_numerator;
Modified: experimental/derf/theora-exp/lib/decinfo.c
===================================================================
--- experimental/derf/theora-exp/lib/decinfo.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/decinfo.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -43,26 +43,28 @@
}
/*Read the encoded frame description.*/
theora_read(_opb,16,&val);
- _info->width=(ogg_uint32_t)val<<4;
+ _info->frame_width=(ogg_uint32_t)val<<4;
theora_read(_opb,16,&val);
- _info->height=(ogg_uint32_t)val<<4;
+ _info->frame_height=(ogg_uint32_t)val<<4;
theora_read(_opb,24,&val);
- _info->frame_width=(ogg_uint32_t)val;
+ _info->pic_width=(ogg_uint32_t)val;
theora_read(_opb,24,&val);
- _info->frame_height=(ogg_uint32_t)val;
+ _info->pic_height=(ogg_uint32_t)val;
theora_read(_opb,8,&val);
- _info->offset_x=(ogg_uint32_t)val;
- /*Note: The sense of offset_y is inverted in what we pass back to the
- application compared to how it is stored in the bitstream.*/
+ _info->pic_x=(ogg_uint32_t)val;
+ /*Note: The sense of pic_y is inverted in what we pass back to the
+ application compared to how it is stored in the bitstream.
+ This is because the bitstream uses a right-handed coordinate system, while
+ applications expect a left-handed one.*/
theora_read(_opb,8,&val);
- _info->offset_y=_info->height-_info->frame_height-(ogg_uint32_t)val;
+ _info->pic_y=_info->frame_height-_info->pic_height-(ogg_uint32_t)val;
theora_read32(_opb,&val);
_info->fps_numerator=(ogg_uint32_t)val;
theora_read32(_opb,&val);
_info->fps_denominator=(ogg_uint32_t)val;
- if(_info->width<=0||_info->height<=0||
- _info->frame_width+_info->offset_x>_info->width||
- _info->frame_height+_info->offset_y>_info->height||
+ if(_info->frame_width<=0||_info->frame_height<=0||
+ _info->pic_width+_info->pic_x>_info->frame_width||
+ _info->pic_height+_info->pic_y>_info->frame_height||
_info->fps_numerator<=0||_info->fps_denominator<=0){
return OC_BADHEADER;
}
@@ -136,7 +138,7 @@
packtype=(int)val;
/*If we're at a data packet and we have received all three headers, we're
done.*/
- if(!(packtype&0x80)&&_info->width>0&&_tc->vendor!=NULL&&*_setup!=NULL){
+ if(!(packtype&0x80)&&_info->frame_width>0&&_tc->vendor!=NULL&&*_setup!=NULL){
return 0;
}
/*Check the codec string.*/
@@ -147,7 +149,7 @@
case 0x80:{
/*This should be the first packet, and we should not already be
initialized.*/
- if(!_op->b_o_s||_info->width>0)return OC_BADHEADER;
+ if(!_op->b_o_s||_info->frame_width>0)return OC_BADHEADER;
ret=oc_info_unpack(_opb,_info);
if(ret<0)theora_info_clear(_info);
else ret=3;
@@ -157,7 +159,7 @@
if(_tc==NULL)return OC_FAULT;
/*We shoud have already decoded the info header, and should not yet have
decoded the comment header.*/
- if(_info->width<=0||_tc->vendor!=NULL)return OC_BADHEADER;
+ if(_info->frame_width<=0||_tc->vendor!=NULL)return OC_BADHEADER;
ret=oc_comment_unpack(_opb,_tc);
if(ret<0)theora_comment_clear(_tc);
else ret=2;
@@ -168,7 +170,7 @@
if(_tc==NULL||_setup==NULL)return OC_FAULT;
/*We should have already decoded the info header and the comment header,
and should not yet have decoded the setup header.*/
- if(_info->width<=0||_tc->vendor==NULL||*_setup!=NULL){
+ if(_info->frame_width<=0||_tc->vendor==NULL||*_setup!=NULL){
return OC_BADHEADER;
}
setup=(oc_setup_info *)_ogg_calloc(1,sizeof(*setup));
Modified: experimental/derf/theora-exp/lib/decode.c
===================================================================
--- experimental/derf/theora-exp/lib/decode.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/decode.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -1627,14 +1627,14 @@
if(_dec->variances==NULL||
_dec->pp_frame_has_chroma!=(_dec->pp_level>=OC_PP_LEVEL_DEBLOCKC)){
size_t frame_sz;
- frame_sz=_dec->state.info.width*_dec->state.info.height;
+ frame_sz=_dec->state.info.frame_width*_dec->state.info.frame_height;
if(_dec->pp_level<OC_PP_LEVEL_DEBLOCKC){
_dec->variances=(ogg_uint32_t *)_ogg_realloc(_dec->variances,
_dec->state.fplanes[0].nfrags*sizeof(_dec->variances[0]));
_dec->pp_frame_data=(unsigned char *)_ogg_realloc(
_dec->pp_frame_data,frame_sz*sizeof(_dec->pp_frame_data[0]));
- _dec->pp_frame_buf[0].width=_dec->state.info.width;
- _dec->pp_frame_buf[0].height=_dec->state.info.height;
+ _dec->pp_frame_buf[0].width=_dec->state.info.frame_width;
+ _dec->pp_frame_buf[0].height=_dec->state.info.frame_height;
_dec->pp_frame_buf[0].ystride=-_dec->pp_frame_buf[0].width;
_dec->pp_frame_buf[0].data=_dec->pp_frame_data+
(1-_dec->pp_frame_buf[0].height)*_dec->pp_frame_buf[0].ystride;
@@ -1647,14 +1647,14 @@
_dec->variances=(int *)_ogg_realloc(_dec->variances,
_dec->state.nfrags*sizeof(_dec->variances[0]));
y_sz=frame_sz;
- c_w=_dec->state.info.width>>!(_dec->state.info.pixel_fmt&1);
- c_h=_dec->state.info.height>>!(_dec->state.info.pixel_fmt&2);
+ c_w=_dec->state.info.frame_width>>!(_dec->state.info.pixel_fmt&1);
+ c_h=_dec->state.info.frame_height>>!(_dec->state.info.pixel_fmt&2);
c_sz=c_w*c_h;
frame_sz+=c_sz<<1;
_dec->pp_frame_data=(unsigned char *)_ogg_realloc(
_dec->pp_frame_data,frame_sz*sizeof(_dec->pp_frame_data[0]));
- _dec->pp_frame_buf[0].width=_dec->state.info.width;
- _dec->pp_frame_buf[0].height=_dec->state.info.height;
+ _dec->pp_frame_buf[0].width=_dec->state.info.frame_width;
+ _dec->pp_frame_buf[0].height=_dec->state.info.frame_height;
_dec->pp_frame_buf[0].ystride=_dec->pp_frame_buf[0].width;
_dec->pp_frame_buf[0].data=_dec->pp_frame_data;
_dec->pp_frame_buf[1].width=c_w;
@@ -1772,10 +1772,10 @@
_dec->state.ref_frame_idx[OC_FRAME_PREV]=0;
_dec->state.ref_frame_idx[OC_FRAME_SELF]=1;
info=&_dec->state.info;
- yhstride=info->width+2*OC_UMV_PADDING;
- yvstride=info->height+2*OC_UMV_PADDING;
- chstride=(info->pixel_fmt&1)?yhstride:yhstride>>1;
- cvstride=(info->pixel_fmt&2)?yvstride:yvstride>>1;
+ yhstride=info->frame_width+2*OC_UMV_PADDING;
+ yvstride=info->frame_height+2*OC_UMV_PADDING;
+ chstride=yhstride>>!(info->pixel_fmt&1);
+ cvstride=yvstride>>!(info->pixel_fmt&2);
yplane_sz=(size_t)yhstride*yvstride;
cplane_sz=(size_t)chstride*cvstride;
memset(_dec->state.ref_frame_data,0x80,yplane_sz+2*cplane_sz);
Modified: experimental/derf/theora-exp/lib/encinfo.c
===================================================================
--- experimental/derf/theora-exp/lib/encinfo.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/encinfo.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -31,13 +31,13 @@
oggpackB_write(&_enc->opb,OC_VERSION_MINOR,8);
oggpackB_write(&_enc->opb,OC_VERSION_SUB,8);
/*Describe the encoded frame.*/
- oggpackB_write(&_enc->opb,_enc->state.info.width>>4,16);
- oggpackB_write(&_enc->opb,_enc->state.info.height>>4,16);
- oggpackB_write(&_enc->opb,_enc->state.info.frame_width,24);
- oggpackB_write(&_enc->opb,_enc->state.info.frame_height,24);
- oggpackB_write(&_enc->opb,_enc->state.info.offset_x,8);
- oggpackB_write(&_enc->opb,_enc->state.info.height-
- _enc->state.info.frame_height-_enc->state.info.offset_y,8);
+ oggpackB_write(&_enc->opb,_enc->state.info.frame_width>>4,16);
+ oggpackB_write(&_enc->opb,_enc->state.info.frame_height>>4,16);
+ oggpackB_write(&_enc->opb,_enc->state.info.pic_width,24);
+ oggpackB_write(&_enc->opb,_enc->state.info.pic_height,24);
+ oggpackB_write(&_enc->opb,_enc->state.info.pic_x,8);
+ oggpackB_write(&_enc->opb,_enc->state.info.frame_height-
+ _enc->state.info.pic_height-_enc->state.info.pic_y,8);
oggpackB_write(&_enc->opb,_enc->state.info.fps_numerator,32);
oggpackB_write(&_enc->opb,_enc->state.info.fps_denominator,32);
oggpackB_write(&_enc->opb,_enc->state.info.aspect_numerator,24);
Modified: experimental/derf/theora-exp/lib/encode.c
===================================================================
--- experimental/derf/theora-exp/lib/encode.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/encode.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -2582,13 +2582,13 @@
/*Step 1: validate parameters.*/
if(_enc==NULL||_img==NULL)return OC_FAULT;
if(_enc->packet_state==OC_PACKET_DONE)return OC_EINVAL;
- if(_img[0].width!=(int)_enc->state.info.width||
- _img[0].height!=(int)_enc->state.info.height){
+ if(_img[0].width!=(int)_enc->state.info.frame_width||
+ _img[0].height!=(int)_enc->state.info.frame_height){
return OC_EINVAL;
}
- cwidth=_enc->state.info.width;
+ cwidth=_enc->state.info.frame_width;
if(!(_enc->state.info.pixel_fmt&1))cwidth>>=1;
- cheight=_enc->state.info.height;
+ cheight=_enc->state.info.frame_height;
if(!(_enc->state.info.pixel_fmt&2))cheight>>=1;
if(_img[1].width!=cwidth||_img[2].width!=cwidth||
_img[1].height!=cheight||_img[2].height!=cheight){
Modified: experimental/derf/theora-exp/lib/impmap.c
===================================================================
--- experimental/derf/theora-exp/lib/impmap.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/impmap.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -357,10 +357,10 @@
float inv_edge_sz_max;
/*The horizontal offset used to convert from image buffer coordinates to
label buffer coordinates.*/
- int offset_x;
+ int pic_x;
/*The vertical offset used to convert from image buffer coordinates to label
buffer coordinates.*/
- int offset_y;
+ int pic_y;
/*The boundaries of each of the three piecewise sections of the importance
function for motion, pre-adjusted to half-pixels/frame.*/
float mot_limits[4];
@@ -2064,8 +2064,8 @@
emb->mvs[0][OC_FRAME_PREV][1]);
iregions=_impmap->regions;
labels=_impmap->seg.labels;
- x0=mb->x-_impmap->offset_x;
- y0=mb->y-_impmap->offset_y;
+ x0=mb->x-_impmap->pic_x;
+ y0=mb->y-_impmap->pic_y;
for(i=0;i<4;i++){
oc_fragment *frag;
oc_fragment_enc_info *efrag;
@@ -2114,15 +2114,15 @@
int width;
int height;
info=&_enc->state.info;
- width=info->frame_width;
- height=info->frame_height;
+ width=info->pic_width;
+ height=info->pic_height;
impmap=(oc_impmap_ctx *)_ogg_malloc(sizeof(*impmap));
oc_seg_init(&impmap->seg,width,height);
impmap->inv_region_sz_max=100.0F/(width*height);
edge_sz=width>1?height>1?(width-2<<1)+(height<<1):width:height;
impmap->inv_edge_sz_max=2.0F/edge_sz;
- impmap->offset_x=info->offset_x;
- impmap->offset_y=info->offset_y;
+ impmap->pic_x=info->pic_x;
+ impmap->pic_y=info->pic_y;
impmap->imp_avg=0.5F;
/*Allocate space for the region stats and neighbor links.*/
impmap->regions=(oc_impmap_region *)_ogg_malloc(
@@ -2151,10 +2151,10 @@
/*TODO: Use the same oc_border_info structure as everyone else.
This would make future integration of an alpha mask easier.*/
img_offset=_impmap->enc->state.input[0].ystride*
- _impmap->enc->state.info.offset_y+_impmap->enc->state.info.offset_x;
+ _impmap->enc->state.info.pic_y+_impmap->enc->state.info.pic_x;
yplane.data=_impmap->enc->state.input[0].data+img_offset;
- yplane.width=_impmap->enc->state.info.frame_width;
- yplane.height=_impmap->enc->state.info.frame_height;
+ yplane.width=_impmap->enc->state.info.pic_width;
+ yplane.height=_impmap->enc->state.info.pic_height;
yplane.ystride=_impmap->enc->state.input[0].ystride;
oc_seg_plane(&_impmap->seg,&yplane);
/*Gather statistics over the segmentation.*/
Modified: experimental/derf/theora-exp/lib/state.c
===================================================================
--- experimental/derf/theora-exp/lib/state.c 2004-09-03 22:42:21 UTC (rev 7693)
+++ experimental/derf/theora-exp/lib/state.c 2004-09-04 00:36:28 UTC (rev 7694)
@@ -275,10 +275,10 @@
fplane=_state->fplanes+pli;
crop=crop_rects+pli;
/*Set up the cropping rectangle for this plane.*/
- crop->x0=_state->info.offset_x;
- crop->xf=_state->info.offset_x+_state->info.frame_width;
- crop->y0=_state->info.offset_y;
- crop->yf=_state->info.offset_y+_state->info.frame_height;
+ crop->x0=_state->info.pic_x;
+ crop->xf=_state->info.pic_x+_state->info.pic_width;
+ crop->y0=_state->info.pic_y;
+ crop->yf=_state->info.pic_y+_state->info.pic_height;
if(pli>0){
if(!(_state->info.pixel_fmt&1)){
crop->x0=crop->x0>>1;
@@ -354,13 +354,17 @@
int csbs;
int nsbs;
int nmbs;
+ int hdec;
+ int vdec;
int pli;
/*Figure out the number of fragments in each plane.*/
/*These parameters have already been validated to be multiples of 16.*/
- yhfrags=_state->info.width>>3;
- yvfrags=_state->info.height>>3;
- chfrags=(_state->info.pixel_fmt&1)?yhfrags:yhfrags+1>>1;
- cvfrags=(_state->info.pixel_fmt&2)?yvfrags:yvfrags+1>>1;
+ yhfrags=_state->info.frame_width>>3;
+ yvfrags=_state->info.frame_height>>3;
+ hdec=!(_state->info.pixel_fmt&1);
+ vdec=!(_state->info.pixel_fmt&2);
+ chfrags=yhfrags+hdec>>hdec;
+ cvfrags=yvfrags+vdec>>vdec;
yfrags=yhfrags*yvfrags;
cfrags=chfrags*cvfrags;
nfrags=yfrags+2*cfrags;
@@ -445,24 +449,24 @@
int rfi;
info=&_state->info;
/*Compute the image buffer parameters for each plane.*/
- yhstride=info->width+2*OC_UMV_PADDING;
- yvstride=info->height+2*OC_UMV_PADDING;
- chstride=(info->pixel_fmt&1)?yhstride:yhstride>>1;
- cvstride=(info->pixel_fmt&2)?yvstride:yvstride>>1;
+ yhstride=info->frame_width+2*OC_UMV_PADDING;
+ yvstride=info->frame_height+2*OC_UMV_PADDING;
+ chstride=yhstride>>!(info->pixel_fmt&1);
+ cvstride=yvstride>>!(info->pixel_fmt&2);
yplane_sz=(size_t)yhstride*yvstride;
cplane_sz=(size_t)chstride*cvstride;
yoffset=OC_UMV_PADDING+OC_UMV_PADDING*yhstride;
- coffset=((info->pixel_fmt&1)?OC_UMV_PADDING:OC_UMV_PADDING>>1)+
- ((info->pixel_fmt&2)?OC_UMV_PADDING:OC_UMV_PADDING>>1)*chstride;
+ coffset=(OC_UMV_PADDING>>!(info->pixel_fmt&1))+
+ (OC_UMV_PADDING>>!(info->pixel_fmt&2))*chstride;
_state->ref_frame_data=ref_frame_data=_ogg_malloc(3*(yplane_sz+2*cplane_sz));
/*Set up the width, height and stride for the image buffers.*/
- _state->ref_frame_bufs[0][0].width=info->width;
- _state->ref_frame_bufs[0][0].height=info->height;
+ _state->ref_frame_bufs[0][0].width=info->frame_width;
+ _state->ref_frame_bufs[0][0].height=info->frame_height;
_state->ref_frame_bufs[0][0].ystride=yhstride;
_state->ref_frame_bufs[0][1].width=_state->ref_frame_bufs[0][2].width=
- (info->pixel_fmt&1)?info->width:info->width>>1;
+ info->frame_width>>!(info->pixel_fmt&1);
_state->ref_frame_bufs[0][1].height=_state->ref_frame_bufs[0][2].height=
- (info->pixel_fmt&2)?info->height:info->height>>1;
+ info->frame_height>>!(info->pixel_fmt&2);
_state->ref_frame_bufs[0][1].ystride=_state->ref_frame_bufs[0][2].ystride=
chstride;
memcpy(_state->ref_frame_bufs[1],_state->ref_frame_bufs[0],
@@ -505,21 +509,21 @@
the bitstream.
The displayable frame must fit inside the encoded frame.
The color space must be one known by the encoder.*/
- if((_info->width&0xF)||(_info->height&0xF)||
- _info->width>=0x100000||_info->height>=0x100000||
- _info->offset_x+_info->frame_width>_info->width||
- _info->offset_y+_info->frame_height>_info->height||
- _info->offset_x>255||
- _info->height-_info->frame_height-_info->offset_y>255||
+ if((_info->frame_width&0xF)||(_info->frame_height&0xF)||
+ _info->frame_width>=0x100000||_info->frame_height>=0x100000||
+ _info->pic_x+_info->pic_width>_info->frame_width||
+ _info->pic_y+_info->pic_height>_info->frame_height||
+ _info->pic_x>255||
+ _info->frame_height-_info->pic_height-_info->pic_y>255||
_info->colorspace<0||_info->colorspace>=OC_CS_NSPACES||
_info->pixel_fmt<0||_info->pixel_fmt>=OC_PF_NFORMATS){
return OC_EINVAL;
}
memset(_state,0,sizeof(*_state));
memcpy(&_state->info,_info,sizeof(*_info));
- /*Invert the sense of offset_y to match Theora's right-handed coordinate
+ /*Invert the sense of pic_y to match Theora's right-handed coordinate
system.*/
- _state->info.offset_y=_info->height-_info->frame_height-_info->offset_y;
+ _state->info.pic_y=_info->frame_height-_info->pic_height-_info->pic_y;
_state->frame_type=OC_UNKWN_FRAME;
oc_state_frarray_init(_state);
oc_state_ref_bufs_init(_state);
@@ -973,8 +977,8 @@
int height;
int imgi;
int imgj;
- width=_state->info.width;
- height=_state->info.height;
+ width=_state->info.frame_width;
+ height=_state->info.frame_height;
iframe=_state->granpos>>_state->info.keyframe_granule_shift;
pframe=_state->granpos-(iframe<<_state->info.keyframe_granule_shift);
sprintf(fname,"%08i%s.png",(int)(iframe+pframe),_suf);
More information about the commits
mailing list