| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  * | 9  * | 
| 10  *  Based on code from the OggTheora software codec source code, | 10  *  Based on code from the OggTheora software codec source code, | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139   |       |       |       | | 139   |       |       |       | | 
| 140   |       |       |       | | 140   |       |       |       | | 
| 141 | 141 | 
| 142   We use a resampling filter to shift the site locations one quarter pixel (at | 142   We use a resampling filter to shift the site locations one quarter pixel (at | 
| 143    the chroma plane's resolution) to the right. | 143    the chroma plane's resolution) to the right. | 
| 144   The 4:2:2 modes look exactly the same, except there are twice as many chroma | 144   The 4:2:2 modes look exactly the same, except there are twice as many chroma | 
| 145    lines, and they are vertically co-sited with the luma samples in both the | 145    lines, and they are vertically co-sited with the luma samples in both the | 
| 146    mpeg2 and jpeg cases (thus requiring no vertical resampling).*/ | 146    mpeg2 and jpeg cases (thus requiring no vertical resampling).*/ | 
| 147 static void y4m_42xmpeg2_42xjpeg_helper(unsigned char *_dst, | 147 static void y4m_42xmpeg2_42xjpeg_helper(unsigned char *_dst, | 
| 148  const unsigned char *_src,int _c_w,int _c_h){ | 148  const unsigned char *_src,int _c_w,int _c_h){ | 
| 149   int pli; |  | 
| 150   int y; | 149   int y; | 
| 151   int x; | 150   int x; | 
| 152   for(y=0;y<_c_h;y++){ | 151   for(y=0;y<_c_h;y++){ | 
| 153     /*Filter: [4 -17 114 35 -9 1]/128, derived from a 6-tap Lanczos | 152     /*Filter: [4 -17 114 35 -9 1]/128, derived from a 6-tap Lanczos | 
| 154        window.*/ | 153        window.*/ | 
| 155     for(x=0;x<OC_MINI(_c_w,2);x++){ | 154     for(x=0;x<OC_MINI(_c_w,2);x++){ | 
| 156       _dst[x]=(unsigned char)OC_CLAMPI(0,(4*_src[0]-17*_src[OC_MAXI(x-1,0)]+ | 155       _dst[x]=(unsigned char)OC_CLAMPI(0,(4*_src[0]-17*_src[OC_MAXI(x-1,0)]+ | 
| 157        114*_src[x]+35*_src[OC_MINI(x+1,_c_w-1)]-9*_src[OC_MINI(x+2,_c_w-1)]+ | 156        114*_src[x]+35*_src[OC_MINI(x+1,_c_w-1)]-9*_src[OC_MINI(x+2,_c_w-1)]+ | 
| 158        _src[OC_MINI(x+3,_c_w-1)]+64)>>7,255); | 157        _src[OC_MINI(x+3,_c_w-1)]+64)>>7,255); | 
| 159     } | 158     } | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 171   } | 170   } | 
| 172 } | 171 } | 
| 173 | 172 | 
| 174 /*Handles both 422 and 420mpeg2 to 422jpeg and 420jpeg, respectively.*/ | 173 /*Handles both 422 and 420mpeg2 to 422jpeg and 420jpeg, respectively.*/ | 
| 175 static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m,unsigned char *_dst, | 174 static void y4m_convert_42xmpeg2_42xjpeg(y4m_input *_y4m,unsigned char *_dst, | 
| 176  unsigned char *_aux){ | 175  unsigned char *_aux){ | 
| 177   int c_w; | 176   int c_w; | 
| 178   int c_h; | 177   int c_h; | 
| 179   int c_sz; | 178   int c_sz; | 
| 180   int pli; | 179   int pli; | 
| 181   int y; |  | 
| 182   int x; |  | 
| 183   /*Skip past the luma data.*/ | 180   /*Skip past the luma data.*/ | 
| 184   _dst+=_y4m->pic_w*_y4m->pic_h; | 181   _dst+=_y4m->pic_w*_y4m->pic_h; | 
| 185   /*Compute the size of each chroma plane.*/ | 182   /*Compute the size of each chroma plane.*/ | 
| 186   c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 183   c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 
| 187   c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 184   c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 
| 188   c_sz=c_w*c_h; | 185   c_sz=c_w*c_h; | 
| 189   for(pli=1;pli<3;pli++){ | 186   for(pli=1;pli<3;pli++){ | 
| 190     y4m_42xmpeg2_42xjpeg_helper(_dst,_aux,c_w,c_h); | 187     y4m_42xmpeg2_42xjpeg_helper(_dst,_aux,c_w,c_h); | 
| 191     _dst+=c_sz; | 188     _dst+=c_sz; | 
| 192     _aux+=c_sz; | 189     _aux+=c_sz; | 
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 389   We use a resampling filter to decimate the chroma planes by two in the | 386   We use a resampling filter to decimate the chroma planes by two in the | 
| 390    vertical direction.*/ | 387    vertical direction.*/ | 
| 391 static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m,unsigned char *_dst, | 388 static void y4m_convert_422jpeg_420jpeg(y4m_input *_y4m,unsigned char *_dst, | 
| 392  unsigned char *_aux){ | 389  unsigned char *_aux){ | 
| 393   int c_w; | 390   int c_w; | 
| 394   int c_h; | 391   int c_h; | 
| 395   int c_sz; | 392   int c_sz; | 
| 396   int dst_c_w; | 393   int dst_c_w; | 
| 397   int dst_c_h; | 394   int dst_c_h; | 
| 398   int dst_c_sz; | 395   int dst_c_sz; | 
| 399   int tmp_sz; |  | 
| 400   int pic_sz; |  | 
| 401   int pli; | 396   int pli; | 
| 402   /*Skip past the luma data.*/ | 397   /*Skip past the luma data.*/ | 
| 403   _dst+=_y4m->pic_w*_y4m->pic_h; | 398   _dst+=_y4m->pic_w*_y4m->pic_h; | 
| 404   /*Compute the size of each chroma plane.*/ | 399   /*Compute the size of each chroma plane.*/ | 
| 405   c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h; | 400   c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h; | 
| 406   c_h=_y4m->pic_h; | 401   c_h=_y4m->pic_h; | 
| 407   dst_c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 402   dst_c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 
| 408   dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 403   dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 
| 409   c_sz=c_w*c_h; | 404   c_sz=c_w*c_h; | 
| 410   dst_c_sz=dst_c_w*dst_c_h; | 405   dst_c_sz=dst_c_w*dst_c_h; | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 454   We use a resampling filter to shift the original site locations one quarter | 449   We use a resampling filter to shift the original site locations one quarter | 
| 455    pixel (at the original chroma resolution) to the right. | 450    pixel (at the original chroma resolution) to the right. | 
| 456   Then we use a second resampling filter to decimate the chroma planes by two | 451   Then we use a second resampling filter to decimate the chroma planes by two | 
| 457    in the vertical direction.*/ | 452    in the vertical direction.*/ | 
| 458 static void y4m_convert_422_420jpeg(y4m_input *_y4m,unsigned char *_dst, | 453 static void y4m_convert_422_420jpeg(y4m_input *_y4m,unsigned char *_dst, | 
| 459  unsigned char *_aux){ | 454  unsigned char *_aux){ | 
| 460   unsigned char *tmp; | 455   unsigned char *tmp; | 
| 461   int            c_w; | 456   int            c_w; | 
| 462   int            c_h; | 457   int            c_h; | 
| 463   int            c_sz; | 458   int            c_sz; | 
| 464   int            dst_c_w; |  | 
| 465   int            dst_c_h; | 459   int            dst_c_h; | 
| 466   int            dst_c_sz; | 460   int            dst_c_sz; | 
| 467   int            pli; | 461   int            pli; | 
| 468   int            y; |  | 
| 469   int            x; |  | 
| 470   /*Skip past the luma data.*/ | 462   /*Skip past the luma data.*/ | 
| 471   _dst+=_y4m->pic_w*_y4m->pic_h; | 463   _dst+=_y4m->pic_w*_y4m->pic_h; | 
| 472   /*Compute the size of each chroma plane.*/ | 464   /*Compute the size of each chroma plane.*/ | 
| 473   c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h; | 465   c_w=(_y4m->pic_w+_y4m->src_c_dec_h-1)/_y4m->src_c_dec_h; | 
| 474   c_h=_y4m->pic_h; | 466   c_h=_y4m->pic_h; | 
| 475   dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 467   dst_c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 
| 476   c_sz=c_w*c_h; | 468   c_sz=c_w*c_h; | 
| 477   dst_c_sz=c_w*dst_c_h; | 469   dst_c_sz=c_w*dst_c_h; | 
| 478   tmp=_aux+2*c_sz; | 470   tmp=_aux+2*c_sz; | 
| 479   for(pli=1;pli<3;pli++){ | 471   for(pli=1;pli<3;pli++){ | 
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 814 } | 806 } | 
| 815 | 807 | 
| 816 void y4m_input_close(y4m_input *_y4m){ | 808 void y4m_input_close(y4m_input *_y4m){ | 
| 817   free(_y4m->dst_buf); | 809   free(_y4m->dst_buf); | 
| 818   free(_y4m->aux_buf); | 810   free(_y4m->aux_buf); | 
| 819 } | 811 } | 
| 820 | 812 | 
| 821 int y4m_input_fetch_frame(y4m_input *_y4m,FILE *_fin,vpx_image_t *_img){ | 813 int y4m_input_fetch_frame(y4m_input *_y4m,FILE *_fin,vpx_image_t *_img){ | 
| 822   char frame[6]; | 814   char frame[6]; | 
| 823   int  pic_sz; | 815   int  pic_sz; | 
| 824   int  frame_c_w; |  | 
| 825   int  frame_c_h; |  | 
| 826   int  c_w; | 816   int  c_w; | 
| 827   int  c_h; | 817   int  c_h; | 
| 828   int  c_sz; | 818   int  c_sz; | 
| 829   int  ret; | 819   int  ret; | 
| 830   /*Read and skip the frame header.*/ | 820   /*Read and skip the frame header.*/ | 
| 831   ret=fread(frame,1,6,_fin); | 821   ret=fread(frame,1,6,_fin); | 
| 832   if(ret<6)return 0; | 822   if(ret<6)return 0; | 
| 833   if(memcmp(frame,"FRAME",5)){ | 823   if(memcmp(frame,"FRAME",5)){ | 
| 834     fprintf(stderr,"Loss of framing in Y4M input data\n"); | 824     fprintf(stderr,"Loss of framing in Y4M input data\n"); | 
| 835     return -1; | 825     return -1; | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 872   c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 862   c_w=(_y4m->pic_w+_y4m->dst_c_dec_h-1)/_y4m->dst_c_dec_h; | 
| 873   c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 863   c_h=(_y4m->pic_h+_y4m->dst_c_dec_v-1)/_y4m->dst_c_dec_v; | 
| 874   c_sz=c_w*c_h; | 864   c_sz=c_w*c_h; | 
| 875   _img->stride[PLANE_Y]=_y4m->pic_w; | 865   _img->stride[PLANE_Y]=_y4m->pic_w; | 
| 876   _img->stride[PLANE_U]=_img->stride[PLANE_V]=c_w; | 866   _img->stride[PLANE_U]=_img->stride[PLANE_V]=c_w; | 
| 877   _img->planes[PLANE_Y]=_y4m->dst_buf; | 867   _img->planes[PLANE_Y]=_y4m->dst_buf; | 
| 878   _img->planes[PLANE_U]=_y4m->dst_buf+pic_sz; | 868   _img->planes[PLANE_U]=_y4m->dst_buf+pic_sz; | 
| 879   _img->planes[PLANE_V]=_y4m->dst_buf+pic_sz+c_sz; | 869   _img->planes[PLANE_V]=_y4m->dst_buf+pic_sz+c_sz; | 
| 880   return 1; | 870   return 1; | 
| 881 } | 871 } | 
| OLD | NEW | 
|---|