diff --git a/media/libtheora/lib/cpu.c b/media/libtheora/lib/cpu.c --- a/media/libtheora/lib/cpu.c +++ b/media/libtheora/lib/cpu.c @@ -149,31 +149,31 @@ static ogg_uint32_t oc_cpu_flags_get(voi :"cc" ); # else oc_detect_cpuid_helper(&eax,&ebx); # endif /*No cpuid.*/ if(eax==ebx)return 0; # endif cpuid(0,eax,ebx,ecx,edx); /* l e t n I e n i u n e G*/ - if(ecx==0x6C65746E&&edx==0x49656E69&&ebx==0x756E6547|| + if((ecx==0x6C65746E&&edx==0x49656E69&&ebx==0x756E6547)|| /* 6 8 x M T e n i u n e G*/ - ecx==0x3638784D&&edx==0x54656E69&&ebx==0x756E6547){ + (ecx==0x3638784D&&edx==0x54656E69&&ebx==0x756E6547)){ /*Intel, Transmeta (tested with Crusoe TM5800):*/ cpuid(1,eax,ebx,ecx,edx); flags=oc_parse_intel_flags(edx,ecx); } /* D M A c i t n e h t u A*/ - else if(ecx==0x444D4163&&edx==0x69746E65&&ebx==0x68747541|| + else if((ecx==0x444D4163&&edx==0x69746E65&&ebx==0x68747541)|| /* C S N y b e d o e G*/ - ecx==0x43534E20&&edx==0x79622065&&ebx==0x646F6547){ + (ecx==0x43534E20&&edx==0x79622065&&ebx==0x646F6547)){ /*AMD, Geode:*/ cpuid(0x80000000,eax,ebx,ecx,edx); if(eax<0x80000001)flags=0; else{ cpuid(0x80000001,eax,ebx,ecx,edx); flags=oc_parse_amd_flags(edx,ecx); } /*Also check for SSE.*/ cpuid(1,eax,ebx,ecx,edx); flags|=oc_parse_intel_flags(edx,ecx); diff --git a/media/libtheora/lib/dec/bitpack.c b/media/libtheora/lib/dec/bitpack.c --- a/media/libtheora/lib/dec/bitpack.c +++ b/media/libtheora/lib/dec/bitpack.c @@ -26,21 +26,21 @@ void theorapackB_readinit(oggpack_buffer memset(_b,0,sizeof(*_b)); _b->buffer=_b->ptr=_buf; _b->storage=_bytes; } int theorapackB_look1(oggpack_buffer *_b,long *_ret){ if(_b->endbyte>=_b->storage){ *_ret=0L; return -1; } - *_ret=(_b->ptr[0]>>7-_b->endbit)&1; + *_ret=(_b->ptr[0]>>(7-_b->endbit))&1; return 0; } void theorapackB_adv1(oggpack_buffer *_b){ if(++(_b->endbit)>7){ _b->endbit=0; _b->ptr++; _b->endbyte++; } } @@ -61,61 +61,61 @@ int theorapackB_read(oggpack_buffer *_b, fail=-1; goto overflow; } /*Special case to avoid reading _b->ptr[0], which might be past the end of the buffer; also skips some useless accounting.*/ else if(!_bits){ *_ret=0L; return 0; } } - ret=_b->ptr[0]<<24+_b->endbit; + ret=_b->ptr[0]<<(24+_b->endbit); if(_bits>8){ - ret|=_b->ptr[1]<<16+_b->endbit; + ret|=_b->ptr[1]<<(16+_b->endbit); if(_bits>16){ - ret|=_b->ptr[2]<<8+_b->endbit; + ret|=_b->ptr[2]<<(8+_b->endbit); if(_bits>24){ ret|=_b->ptr[3]<<_b->endbit; - if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; + if(_bits>32)ret|=_b->ptr[4]>>(8-_b->endbit); } } } - *_ret=((ret&0xFFFFFFFFUL)>>(m>>1))>>(m+1>>1); + *_ret=((ret&0xFFFFFFFFUL)>>(m>>1))>>((m+1)>>1); fail=0; overflow: _b->ptr+=_bits>>3; _b->endbyte+=_bits>>3; _b->endbit=_bits&7; return fail; } int theorapackB_read1(oggpack_buffer *_b,long *_ret){ int fail; if(_b->endbyte>=_b->storage){ /*Not the main path.*/ *_ret=0L; fail=-1; } else{ - *_ret=(_b->ptr[0]>>7-_b->endbit)&1; + *_ret=(_b->ptr[0]>>(7-_b->endbit))&1; fail=0; } _b->endbit++; if(_b->endbit>7){ _b->endbit=0; _b->ptr++; _b->endbyte++; } return fail; } long theorapackB_bytes(oggpack_buffer *_b){ - return _b->endbyte+(_b->endbit+7>>3); + return _b->endbyte+((_b->endbit+7)>>3); } long theorapackB_bits(oggpack_buffer *_b){ return _b->endbyte*8+_b->endbit; } unsigned char *theorapackB_get_buffer(oggpack_buffer *_b){ return _b->buffer; } diff --git a/media/libtheora/lib/dec/decinfo.c b/media/libtheora/lib/dec/decinfo.c --- a/media/libtheora/lib/dec/decinfo.c +++ b/media/libtheora/lib/dec/decinfo.c @@ -48,22 +48,22 @@ static int oc_info_unpack(oggpack_buffer /*Check the codec bitstream version.*/ theorapackB_read(_opb,8,&val); _info->version_major=(unsigned char)val; theorapackB_read(_opb,8,&val); _info->version_minor=(unsigned char)val; theorapackB_read(_opb,8,&val); _info->version_subminor=(unsigned char)val; /*verify we can parse this bitstream version. We accept earlier minors and all subminors, by spec*/ if(_info->version_major>TH_VERSION_MAJOR|| - _info->version_major==TH_VERSION_MAJOR&& - _info->version_minor>TH_VERSION_MINOR){ + (_info->version_major==TH_VERSION_MAJOR&& + _info->version_minor>TH_VERSION_MINOR)){ return TH_EVERSION; } /*Read the encoded frame description.*/ theorapackB_read(_opb,16,&val); _info->frame_width=(ogg_uint32_t)val<<4; theorapackB_read(_opb,16,&val); _info->frame_height=(ogg_uint32_t)val<<4; theorapackB_read(_opb,24,&val); _info->pic_width=(ogg_uint32_t)val; theorapackB_read(_opb,24,&val); diff --git a/media/libtheora/lib/dec/decode.c b/media/libtheora/lib/dec/decode.c --- a/media/libtheora/lib/dec/decode.c +++ b/media/libtheora/lib/dec/decode.c @@ -168,24 +168,24 @@ static int oc_dec_init(oc_dec_ctx *_dec, for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ _dec->state.dequant_tables[qti][pli]= _dec->state.dequant_table_data[qti][pli]; } oc_dequant_tables_init(_dec->state.dequant_tables,_dec->pp_dc_scale, &_setup->qinfo); for(qi=0;qi<64;qi++){ int qsum; qsum=0; for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){ - qsum+=_dec->state.dequant_tables[qti][pli][qi][18]+ + qsum+=(_dec->state.dequant_tables[qti][pli][qi][18]+ _dec->state.dequant_tables[qti][pli][qi][19]+ _dec->state.dequant_tables[qti][pli][qi][26]+ - _dec->state.dequant_tables[qti][pli][qi][27]<<(pli==0); + _dec->state.dequant_tables[qti][pli][qi][27])<<(pli==0); } _dec->pp_sharp_mod[qi]=-(qsum>>11); } _dec->dct_tokens=(unsigned char **)oc_calloc_2d(64, _dec->state.nfrags,sizeof(_dec->dct_tokens[0][0])); _dec->extra_bits=(ogg_uint16_t **)oc_calloc_2d(64, _dec->state.nfrags,sizeof(_dec->extra_bits[0][0])); memcpy(_dec->state.loop_filter_limits,_setup->qinfo.loop_filter_limits, sizeof(_dec->state.loop_filter_limits)); _dec->pp_level=OC_PP_LEVEL_DISABLED; @@ -495,21 +495,21 @@ static int oc_vlc_mv_comp_unpack(oggpack case 2:return -1; case 3: case 4:{ mvsigned[0]=(int)(bits-1); theorapackB_read1(_opb,&bits); }break; /*case 5: case 6: case 7:*/ default:{ - mvsigned[0]=1<>1); bits&=1; }break; } mvsigned[1]=-mvsigned[0]; return mvsigned[bits]; } static int oc_clc_mv_comp_unpack(oggpack_buffer *_opb){ @@ -1475,32 +1475,32 @@ static void oc_filter_hedge(unsigned cha csrc+=_src_ystride; } sum0=sum1=0; for(by=0;by<4;by++){ sum0+=abs(r[by+1]-r[by]); sum1+=abs(r[by+5]-r[by+6]); } *_variance0+=OC_MINI(255,sum0); *_variance1+=OC_MINI(255,sum1); if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){ - *cdst=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3); + *cdst=(unsigned char)((r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4)>>3); cdst+=_dst_ystride; - *cdst=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3); + *cdst=(unsigned char)((r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4)>>3); cdst+=_dst_ystride; for(by=0;by<4;by++){ - *cdst=(unsigned char)(r[by]+r[by+1]+r[by+2]+r[by+3]*2+ - r[by+4]+r[by+5]+r[by+6]+4>>3); + *cdst=(unsigned char)((r[by]+r[by+1]+r[by+2]+r[by+3]*2+ + r[by+4]+r[by+5]+r[by+6]+4)>>3); cdst+=_dst_ystride; } - *cdst=(unsigned char)(r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4>>3); + *cdst=(unsigned char)((r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4)>>3); cdst+=_dst_ystride; - *cdst=(unsigned char)(r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4>>3); + *cdst=(unsigned char)((r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4)>>3); } else{ for(by=1;by<=8;by++){ *cdst=(unsigned char)r[by]; cdst+=_dst_ystride; } } rdst++; rsrc++; } @@ -1523,28 +1523,28 @@ static void oc_filter_vedge(unsigned cha rdst=cdst; for(bx=0;bx<10;bx++)r[bx]=*rsrc++; sum0=sum1=0; for(bx=0;bx<4;bx++){ sum0+=abs(r[bx+1]-r[bx]); sum1+=abs(r[bx+5]-r[bx+6]); } _variances[0]+=OC_MINI(255,sum0); _variances[1]+=OC_MINI(255,sum1); if(sum0<_flimit&&sum1<_flimit&&r[5]-r[4]<_qstep&&r[4]-r[5]<_qstep){ - *rdst++=(unsigned char)(r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4>>3); - *rdst++=(unsigned char)(r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4>>3); + *rdst++=(unsigned char)((r[0]*3+r[1]*2+r[2]+r[3]+r[4]+4)>>3); + *rdst++=(unsigned char)((r[0]*2+r[1]+r[2]*2+r[3]+r[4]+r[5]+4)>>3); for(bx=0;bx<4;bx++){ - *rdst++=(unsigned char)(r[bx]+r[bx+1]+r[bx+2]+r[bx+3]*2+ - r[bx+4]+r[bx+5]+r[bx+6]+4>>3); + *rdst++=(unsigned char)((r[bx]+r[bx+1]+r[bx+2]+r[bx+3]*2+ + r[bx+4]+r[bx+5]+r[bx+6]+4)>>3); } - *rdst++=(unsigned char)(r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4>>3); - *rdst=(unsigned char)(r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4>>3); + *rdst++=(unsigned char)((r[4]+r[5]+r[6]+r[7]*2+r[8]+r[9]*2+4)>>3); + *rdst=(unsigned char)((r[5]+r[6]+r[7]+r[8]*2+r[9]*3+4)>>3); } else for(bx=1;bx<=8;bx++)*rdst++=(unsigned char)r[bx]; cdst+=_dst_ystride; } } static void oc_dec_deblock_frag_rows(oc_dec_ctx *_dec, th_img_plane *_dst,th_img_plane *_src,int _pli,int _fragy0, int _fragy_end){ oc_fragment_plane *fplane; @@ -1574,21 +1574,21 @@ static void oc_dec_deblock_frag_rows(oc_ /*Except for the first time, we want to point to the middle of the row.*/ y=(_fragy0<<3)+(notstart<<2); dst=_dst->data+y*_dst->stride; src=_src->data+y*_src->stride; for(;y<4;y++){ memcpy(dst,src,_dst->width*sizeof(dst[0])); dst+=_dst->stride; src+=_src->stride; } /*We also want to skip the last row in the frame for this loop.*/ - y_end=_fragy_end-!notdone<<3; + y_end=(_fragy_end-!notdone)<<3; for(;ypp_dc_scale[*dc_qi]; flimit=(qstep*3)>>2; oc_filter_hedge(dst,_dst->stride,src-_src->stride,_src->stride, qstep,flimit,variance,variance+fplane->nhfrags); variance++; dc_qi++; for(x=8;x<_dst->width;x+=8){ qstep=_dec->pp_dc_scale[*dc_qi]; flimit=(qstep*3)>>2; @@ -1637,94 +1637,94 @@ static void oc_dering_block(unsigned cha dst=_idata; src=dst; psrc=src-(_ystride&-!(_b&4)); for(by=0;by<9;by++){ for(bx=0;bx<8;bx++){ int mod; mod=32+_dc_scale-(abs(src[bx]-psrc[bx])<>7); + dst[0]=OC_CLAMP255((a*src[0]+b)>>7); for(bx=1;bx<7;bx++){ a=128; b=64; w=hmod[(bx<<3)+by]; a-=w; b+=w*src[bx-1]; w=vmod[(by<<3)+bx]; a-=w; b+=w*psrc[bx]; - w=vmod[(by+1<<3)+bx]; + w=vmod[((by+1)<<3)+bx]; a-=w; b+=w*nsrc[bx]; - w=hmod[(bx+1<<3)+by]; + w=hmod[((bx+1)<<3)+by]; a-=w; b+=w*src[bx+1]; - dst[bx]=OC_CLAMP255(a*src[bx]+b>>7); + dst[bx]=OC_CLAMP255((a*src[bx]+b)>>7); } a=128; b=64; w=hmod[(7<<3)+by]; a-=w; b+=w*src[6]; w=vmod[(by<<3)+7]; a-=w; b+=w*psrc[7]; - w=vmod[(by+1<<3)+7]; + w=vmod[((by+1)<<3)+7]; a-=w; b+=w*nsrc[7]; w=hmod[(8<<3)+by]; a-=w; b+=w*src[7+!(_b&2)]; - dst[7]=OC_CLAMP255(a*src[7]+b>>7); + dst[7]=OC_CLAMP255((a*src[7]+b)>>7); dst+=_ystride; psrc=src; src=nsrc; - nsrc+=_ystride&-(!(_b&8)|by<6); + nsrc+=_ystride&-(!(_b&8)|(by<6)); } } #define OC_DERING_THRESH1 (384) #define OC_DERING_THRESH2 (4*OC_DERING_THRESH1) #define OC_DERING_THRESH3 (5*OC_DERING_THRESH1) #define OC_DERING_THRESH4 (10*OC_DERING_THRESH1) static void oc_dec_dering_frag_rows(oc_dec_ctx *_dec,th_img_plane *_img, int _pli,int _fragy0,int _fragy_end){ @@ -1753,24 +1753,24 @@ static void oc_dec_dering_frag_rows(oc_d for(x=0;xwidth;x+=8){ int b; int qi; int var; qi=frag->qi; var=*variance; b=(x<=0)|(x+8>=iplane->width)<<1|(y<=0)<<2|(y+8>=iplane->height)<<3; if(strong&&var>sthresh){ oc_dering_block(idata+x,iplane->stride,b, _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); - if(_pli||!(b&1)&&*(variance-1)>OC_DERING_THRESH4|| - !(b&2)&&variance[1]>OC_DERING_THRESH4|| - !(b&4)&&*(variance-fplane->nvfrags)>OC_DERING_THRESH4|| - !(b&8)&&variance[fplane->nvfrags]>OC_DERING_THRESH4){ + if(_pli||(!(b&1)&&*(variance-1)>OC_DERING_THRESH4)|| + (!(b&2)&&variance[1]>OC_DERING_THRESH4)|| + (!(b&4)&&*(variance-fplane->nvfrags)>OC_DERING_THRESH4)|| + (!(b&8)&&variance[fplane->nvfrags]>OC_DERING_THRESH4)){ oc_dering_block(idata+x,iplane->stride,b, _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); oc_dering_block(idata+x,iplane->stride,b, _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); } } else if(var>OC_DERING_THRESH2){ oc_dering_block(idata+x,iplane->stride,b, _dec->pp_dc_scale[qi],_dec->pp_sharp_mod[qi],1); } @@ -1828,21 +1828,21 @@ int th_decode_ctl(th_dec_ctx *_dec,int _ case TH_DECCTL_SET_GRANPOS:{ ogg_int64_t granpos; if(_dec==NULL||_buf==NULL)return TH_EFAULT; if(_buf_sz!=sizeof(ogg_int64_t))return TH_EINVAL; granpos=*(ogg_int64_t *)_buf; if(granpos<0)return TH_EINVAL; _dec->state.granpos=granpos; _dec->state.keyframe_num= granpos>>_dec->state.info.keyframe_granule_shift; _dec->state.curframe_num=_dec->state.keyframe_num+ - (granpos&(1<<_dec->state.info.keyframe_granule_shift)-1); + (granpos&((1<<_dec->state.info.keyframe_granule_shift)-1)); return 0; }break; case TH_DECCTL_SET_STRIPE_CB:{ th_stripe_callback *cb; if(_dec==NULL||_buf==NULL)return TH_EFAULT; if(_buf_sz!=sizeof(th_stripe_callback))return TH_EINVAL; cb=(th_stripe_callback *)_buf; _dec->stripe_cb.ctx=cb->ctx; _dec->stripe_cb.stripe_decoded=cb->stripe_decoded; return 0; @@ -1970,22 +1970,22 @@ int th_decode_packetin(th_dec_ctx *_dec, sdelay+=notstart; edelay+=notdone; oc_state_loop_filter_frag_rows(&_dec->state,pipe.bounding_values, refi,pli,pipe.fragy0[pli]-sdelay,pipe.fragy_end[pli]-edelay); } /*To fill the borders, we have an additional two pixel delay, since a fragment in the next row could filter its top edge, using two pixels from a fragment in this row. But there's no reason to delay a full fragment between the two.*/ oc_state_borders_fill_rows(&_dec->state,refi,pli, - (pipe.fragy0[pli]-sdelay<<3)-(sdelay<<1), - (pipe.fragy_end[pli]-edelay<<3)-(edelay<<1)); + ((pipe.fragy0[pli]-sdelay)<<3)-(sdelay<<1), + ((pipe.fragy_end[pli]-edelay)<<3)-(edelay<<1)); /*Out-of-loop post-processing.*/ pp_offset=3*(pli!=0); if(pipe.pp_level>=OC_PP_LEVEL_DEBLOCKY+pp_offset){ /*Perform de-blocking in one plane.*/ sdelay+=notstart; edelay+=notdone; oc_dec_deblock_frag_rows(_dec,_dec->pp_frame_buf, _dec->state.ref_frame_bufs[refi],pli, pipe.fragy0[pli]-sdelay,pipe.fragy_end[pli]-edelay); if(pipe.pp_level>=OC_PP_LEVEL_DERINGY+pp_offset){ @@ -2000,23 +2000,23 @@ int th_decode_packetin(th_dec_ctx *_dec, loop filter, thanks to the strange filtering order VP3 chose.*/ else if(pipe.loop_filter){ sdelay+=notstart; edelay+=notdone; } /*Compute the intersection of the available rows in all planes. If chroma is sub-sampled, the effect of each of its delays is doubled, but luma might have more post-processing filters enabled than chroma, so we don't know up front which one is the limiting factor.*/ - avail_fragy0=OC_MINI(avail_fragy0,pipe.fragy0[pli]-sdelay<stripe_cb.stripe_decoded!=NULL){ /*Make the callback, ensuring we flip the sense of the "start" and "end" of the available region upside down.*/ (*_dec->stripe_cb.stripe_decoded)(_dec->stripe_cb.ctx,stripe_buf, _dec->state.fplanes[0].nvfrags-avail_fragy_end, _dec->state.fplanes[0].nvfrags-avail_fragy0); } notstart=1; } diff --git a/media/libtheora/lib/dec/fragment.c b/media/libtheora/lib/dec/fragment.c --- a/media/libtheora/lib/dec/fragment.c +++ b/media/libtheora/lib/dec/fragment.c @@ -67,21 +67,21 @@ void oc_frag_recon_inter2(const oc_theor void oc_frag_recon_inter2_c(unsigned char *_dst,int _dst_ystride, const unsigned char *_src1,int _src1_ystride,const unsigned char *_src2, int _src2_ystride,const ogg_int16_t *_residue){ int i; for(i=0;i<8;i++){ int j; for(j=0;j<8;j++){ int res; res=*_residue++; - _dst[j]=OC_CLAMP255(res+((int)_src1[j]+_src2[j]>>1)); + _dst[j]=OC_CLAMP255(res+(((int)_src1[j]+_src2[j])>>1)); } _dst+=_dst_ystride; _src1+=_src1_ystride; _src2+=_src2_ystride; } } /*Computes the predicted DC value for the given fragment. This requires that the fully decoded DC values be available for the left, upper-left, upper, and upper-right fragments (if they exist). diff --git a/media/libtheora/lib/dec/huffdec.c b/media/libtheora/lib/dec/huffdec.c --- a/media/libtheora/lib/dec/huffdec.c +++ b/media/libtheora/lib/dec/huffdec.c @@ -40,32 +40,32 @@ static int theorapackB_look(oggpack_buff d=_b->storage-_b->endbyte; if(d<=4){ /*Not the main path.*/ if(d<=0){ *_ret=0L; return -(_bits>d*8); } /*If we have some bits left, but not enough, return the ones we have.*/ if(d*8<_bits)_bits=d*8; } - ret=_b->ptr[0]<<24+_b->endbit; + ret=_b->ptr[0]<<(24+_b->endbit); if(_bits>8){ - ret|=_b->ptr[1]<<16+_b->endbit; + ret|=_b->ptr[1]<<(16+_b->endbit); if(_bits>16){ - ret|=_b->ptr[2]<<8+_b->endbit; + ret|=_b->ptr[2]<<(8+_b->endbit); if(_bits>24){ ret|=_b->ptr[3]<<_b->endbit; - if(_bits>32)ret|=_b->ptr[4]>>8-_b->endbit; + if(_bits>32)ret|=_b->ptr[4]>>(8-_b->endbit); } } } - *_ret=((ret&0xFFFFFFFF)>>(m>>1))>>(m+1>>1); + *_ret=((ret&0xFFFFFFFF)>>(m>>1))>>((m+1)>>1); return 0; } /*advance the bitptr*/ static void theorapackB_adv(oggpack_buffer *_b,int _bits){ _bits+=_b->endbit; _b->ptr+=_bits>>3; _b->endbyte+=_bits>>3; _b->endbit=_bits&7; } @@ -116,21 +116,21 @@ static void oc_huff_node_free(oc_huff_no _node: The Huffman tree to free. This may be NULL.*/ static void oc_huff_tree_free(oc_huff_node *_node){ if(_node==NULL)return; if(_node->nbits){ int nchildren; int i; int inext; nchildren=1<<_node->nbits; for(i=0;inodes[i]!=NULL?1<<_node->nbits-_node->nodes[i]->depth:1); + inext=i+(_node->nodes[i]!=NULL?1<<(_node->nbits-_node->nodes[i]->depth):1); oc_huff_tree_free(_node->nodes[i]); } } oc_huff_node_free(_node); } /*Unpacks a sub-tree from the given buffer. _opb: The buffer to unpack from. _binode: The location to store a pointer to the sub-tree in. _depth: The current depth of the tree. @@ -262,21 +262,21 @@ static oc_huff_node *oc_huff_tree_copy(c oc_huff_node *ret; ret=oc_huff_node_alloc(_node->nbits); ret->depth=_node->depth; if(_node->nbits){ int nchildren; int i; int inext; nchildren=1<<_node->nbits; for(i=0;inodes[i]=oc_huff_tree_copy(_node->nodes[i]); - inext=i+(1<<_node->nbits-ret->nodes[i]->depth); + inext=i+(1<<(_node->nbits-ret->nodes[i]->depth)); while(++inodes[i]=ret->nodes[i-1]; } } else ret->token=_node->token; return ret; } /*Unpacks a set of Huffman trees, and reduces them to a collapsed representation. _opb: The buffer to unpack the trees from. diff --git a/media/libtheora/lib/dec/ocintrin.h b/media/libtheora/lib/dec/ocintrin.h --- a/media/libtheora/lib/dec/ocintrin.h +++ b/media/libtheora/lib/dec/ocintrin.h @@ -41,35 +41,35 @@ static int oc_mini(int _a,int _b){ _a: The lower bound. _b: The value to clamp. _c: The upper boud.*/ #define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c))) #define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255)))) /*Divides an integer by a power of two, truncating towards 0. _dividend: The integer to divide. _shift: The non-negative power of two to divide by. _rmask: (1<<_shift)-1*/ #define OC_DIV_POW2(_dividend,_shift,_rmask)\ - ((_dividend)+(((_dividend)>>sizeof(_dividend)*8-1)&(_rmask))>>(_shift)) + ((_dividend)+(((_dividend)>>(sizeof(_dividend)*8-1))&(_rmask))>>(_shift)) /*Divides _x by 65536, truncating towards 0.*/ #define OC_DIV2_16(_x) OC_DIV_POW2(_x,16,0xFFFF) /*Divides _x by 2, truncating towards 0.*/ #define OC_DIV2(_x) OC_DIV_POW2(_x,1,0x1) /*Divides _x by 8, truncating towards 0.*/ #define OC_DIV8(_x) OC_DIV_POW2(_x,3,0x7) /*Divides _x by 16, truncating towards 0.*/ #define OC_DIV16(_x) OC_DIV_POW2(_x,4,0xF) /*Right shifts _dividend by _shift, adding _rval, and subtracting one for negative dividends first.. When _rval is (1<<_shift-1), this is equivalent to division with rounding ties towards positive infinity.*/ #define OC_DIV_ROUND_POW2(_dividend,_shift,_rval)\ - ((_dividend)+((_dividend)>>sizeof(_dividend)*8-1)+(_rval)>>(_shift)) + (((_dividend)+((_dividend)>>(sizeof(_dividend)*8-1))+(_rval))>>(_shift)) /*Swaps two integers _a and _b if _a>_b.*/ #define OC_SORT2I(_a,_b)\ if((_a)>(_b)){\ int t__;\ t__=(_a);\ (_a)=(_b);\ (_b)=t__;\ } diff --git a/media/libtheora/lib/dec/state.c b/media/libtheora/lib/dec/state.c --- a/media/libtheora/lib/dec/state.c +++ b/media/libtheora/lib/dec/state.c @@ -303,44 +303,44 @@ static void oc_state_border_init(oc_theo fplane=_state->fplanes+pli; crop=crop_rects+pli; /*Set up the cropping rectangle for this plane.*/ 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; - crop->xf=crop->xf+1>>1; + crop->xf=(crop->xf+1)>>1; } if(!(_state->info.pixel_fmt&2)){ crop->y0=crop->y0>>1; - crop->yf=crop->yf+1>>1; + crop->yf=(crop->yf+1)>>1; } } y=0; for(yfrag_end+=fplane->nfrags;fragnhfrags;fragx0||crop->xf<=x||y+8<=crop->y0||crop->yf<=y|| crop->x0>=crop->xf||crop->y0>=crop->yf){ frag->invalid=1; } /*Otherwise, check to see if it straddles the border.*/ - else if(xx0&&crop->x0xf&&crop->xfy0&&crop->y0yf&&crop->yfx0&&crop->x0xf&&crop->xfy0&&crop->y0yf&&crop->yf=crop->x0&&x+jxf&&y+i>=crop->y0&&y+iyf){ mask|=(ogg_int64_t)1<<(i<<3|j); npixels++; @@ -384,30 +384,30 @@ static void oc_state_frarray_init(oc_the 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.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; + chfrags=(yhfrags+hdec)>>hdec; + cvfrags=(yvfrags+vdec)>>vdec; yfrags=yhfrags*yvfrags; cfrags=chfrags*cvfrags; nfrags=yfrags+2*cfrags; /*Figure out the number of super blocks in each plane.*/ - yhsbs=yhfrags+3>>2; - yvsbs=yvfrags+3>>2; - chsbs=chfrags+3>>2; - cvsbs=cvfrags+3>>2; + yhsbs=(yhfrags+3)>>2; + yvsbs=(yvfrags+3)>>2; + chsbs=(chfrags+3)>>2; + cvsbs=(cvfrags+3)>>2; ysbs=yhsbs*yvsbs; csbs=chsbs*cvsbs; nsbs=ysbs+2*csbs; nmbs=ysbs<<2; /*Initialize the fragment array.*/ _state->fplanes[0].nhfrags=yhfrags; _state->fplanes[0].nvfrags=yvfrags; _state->fplanes[0].froffset=0; _state->fplanes[0].nfrags=yfrags; _state->fplanes[0].nhsbs=yhsbs; @@ -753,22 +753,22 @@ int oc_state_get_mv_offsets(oc_theora_st No third or fourth offsets are computed, even if both components have non-zero fractional parts. The second offset is computed by dividing (not shifting) by the appropriate amount, always truncating _away_ from zero.*/ /*These two variables decide whether we are in half- or quarter-pixel precision in each component.*/ xprec=1+(!(_state->info.pixel_fmt&1)&&_pli); yprec=1+(!(_state->info.pixel_fmt&2)&&_pli); /*These two variables are either 0 if all the fractional bits are 0 or 1 if any of them are non-zero.*/ - xfrac=!!(_dx&(1<>xprec)+(_dy>>yprec)*_ystride; if(xfrac||yfrac){ /*This branchless code is equivalent to: if(_dx<0)_offests[0]=-(-_dx>>xprec); else _offsets[0]=(_dx>>xprec); if(_dy<0)_offsets[0]-=(-_dy>>yprec)*_ystride; else _offsets[0]+=(_dy>>yprec)*_ystride; _offsets[1]=_offsets[0]; if(xfrac){ if(_dx<0)_offsets[1]++; @@ -824,21 +824,21 @@ void oc_state_frag_recon_c(oc_theora_sta ends with a long zero run instead of a normal EOB token. It could be smarter... multiple separate zero runs at the end of a block will fool it, but an encoder that generates these really deserves what it gets. Needless to say we inherited this approach from VP3.*/ /*Special case only having a DC component.*/ if(_last_zzi<2){ ogg_int16_t p; /*Why is the iquant product rounded in this case and no others? Who knows.*/ - p=(ogg_int16_t)((ogg_int32_t)_frag->dc*_dc_iquant+15>>5); + p=(ogg_int16_t)(((ogg_int32_t)_frag->dc*_dc_iquant+15)>>5); /*LOOP VECTORIZES.*/ for(ci=0;ci<64;ci++)res_buf[ci]=p; } else{ /*First, dequantize the coefficients.*/ dct_buf[0]=(ogg_int16_t)((ogg_int32_t)_frag->dc*_dc_iquant); for(zzi=1;zzi<_ncoefs;zzi++){ int ci; ci=OC_FZIG_ZAG[zzi]; dct_buf[ci]=(ogg_int16_t)((ogg_int32_t)_dct_coeffs[zzi]*_ac_iquant[ci]); @@ -925,37 +925,37 @@ void oc_state_frag_copy_c(const oc_theor static void loop_filter_h(unsigned char *_pix,int _ystride,int *_bv){ int y; _pix-=2; for(y=0;y<8;y++){ int f; f=_pix[0]-_pix[3]+3*(_pix[2]-_pix[1]); /*The _bv array is used to compute the function f=OC_CLAMPI(OC_MINI(-_2flimit-f,0),f,OC_MAXI(_2flimit-f,0)); where _2flimit=_state->loop_filter_limits[_state->qis[0]]<<1;*/ - f=*(_bv+(f+4>>3)); + f=*(_bv+((f+4)>>3)); _pix[1]=OC_CLAMP255(_pix[1]+f); _pix[2]=OC_CLAMP255(_pix[2]-f); _pix+=_ystride; } } static void loop_filter_v(unsigned char *_pix,int _ystride,int *_bv){ int y; _pix-=_ystride*2; for(y=0;y<8;y++){ int f; f=_pix[0]-_pix[_ystride*3]+3*(_pix[_ystride*2]-_pix[_ystride]); /*The _bv array is used to compute the function f=OC_CLAMPI(OC_MINI(-_2flimit-f,0),f,OC_MAXI(_2flimit-f,0)); where _2flimit=_state->loop_filter_limits[_state->qis[0]]<<1;*/ - f=*(_bv+(f+4>>3)); + f=*(_bv+((f+4)>>3)); _pix[_ystride]=OC_CLAMP255(_pix[_ystride]+f); _pix[_ystride*2]=OC_CLAMP255(_pix[_ystride*2]-f); _pix++; } } /*Initialize the bounding values array used by the loop filter. _bv: Storage for the array. Return: 0 on success, or a non-zero value if no filtering need be applied.*/ int oc_state_loop_filter_init(oc_theora_state *_state,int *_bv){ diff --git a/media/libtheora/lib/dec/x86/mmxstate.c b/media/libtheora/lib/dec/x86/mmxstate.c --- a/media/libtheora/lib/dec/x86/mmxstate.c +++ b/media/libtheora/lib/dec/x86/mmxstate.c @@ -65,21 +65,21 @@ void oc_state_frag_recon_mmx(oc_theora_s ends with a long zero run instead of a normal EOB token. It could be smarter... multiple separate zero runs at the end of a block will fool it, but an encoder that generates these really deserves what it gets. Needless to say we inherited this approach from VP3.*/ /*Special case only having a DC component.*/ if(_last_zzi<2){ ogg_uint16_t p; /*Why is the iquant product rounded in this case and no others? Who knows.*/ - p=(ogg_int16_t)((ogg_int32_t)_frag->dc*_dc_iquant+15>>5); + p=(ogg_int16_t)(((ogg_int32_t)_frag->dc*_dc_iquant+15)>>5); /*Fill res_buf with p.*/ __asm__ __volatile__( /*mm0=0000 0000 0000 AAAA*/ "movd %[p],%%mm0\n\t" /*mm1=0000 0000 0000 AAAA*/ "movd %[p],%%mm1\n\t" /*mm0=0000 0000 AAAA 0000*/ "pslld $16,%%mm0\n\t" /*mm0=0000 0000 AAAA AAAA*/ "por %%mm1,%%mm0\n\t" diff --git a/media/libtheora/lib/internal.h b/media/libtheora/lib/internal.h --- a/media/libtheora/lib/internal.h +++ b/media/libtheora/lib/internal.h @@ -34,23 +34,23 @@ # endif /*This library's version.*/ # define OC_VENDOR_STRING "Xiph.Org libTheora I 20081020 3 2 1" /*Theora bitstream version.*/ # define TH_VERSION_MAJOR (3) # define TH_VERSION_MINOR (2) # define TH_VERSION_SUB (1) # define TH_VERSION_CHECK(_info,_maj,_min,_sub) \ - ((_info)->version_major>(_maj)||(_info)->version_major==(_maj)&& \ - ((_info)->version_minor>(_min)||(_info)->version_minor==(_min)&& \ - (_info)->version_subminor>=(_sub))) + ((_info)->version_major>(_maj)||((_info)->version_major==(_maj)&& \ + ((_info)->version_minor>(_min)))||(((_info)->version_minor==(_min)&& \ + (_info)->version_subminor>=(_sub)))) /*A keyframe.*/ #define OC_INTRA_FRAME (0) /*A predicted frame.*/ #define OC_INTER_FRAME (1) /*A frame of unknown type (frame type decision has not yet been made).*/ #define OC_UNKWN_FRAME (-1) /*The amount of padding to add to the reconstructed frame buffers on all sides.