Mercurial > libavcodec.hg
comparison h264.c @ 1234:fc2a7eefa9cc libavcodec
svq3 decoder by anonymous
author | michaelni |
---|---|
date | Fri, 09 May 2003 22:16:14 +0000 |
parents | ad21a7b2349b |
children | fa181d095027 |
comparison
equal
deleted
inserted
replaced
1233:5d66713e97e2 | 1234:fc2a7eefa9cc |
---|---|
193 uint16_t *mb2b_xy; //FIXME are these 4 a good idea? | 193 uint16_t *mb2b_xy; //FIXME are these 4 a good idea? |
194 uint16_t *mb2b8_xy; | 194 uint16_t *mb2b8_xy; |
195 int b_stride; | 195 int b_stride; |
196 int b8_stride; | 196 int b8_stride; |
197 | 197 |
198 int halfpel_flag; | |
199 int thirdpel_flag; | |
200 | |
198 SPS sps_buffer[MAX_SPS_COUNT]; | 201 SPS sps_buffer[MAX_SPS_COUNT]; |
199 SPS sps; ///< current sps | 202 SPS sps; ///< current sps |
200 | 203 |
201 PPS pps_buffer[MAX_PPS_COUNT]; | 204 PPS pps_buffer[MAX_PPS_COUNT]; |
202 /** | 205 /** |
288 static VLC total_zeros_vlc[15]; | 291 static VLC total_zeros_vlc[15]; |
289 static VLC chroma_dc_total_zeros_vlc[3]; | 292 static VLC chroma_dc_total_zeros_vlc[3]; |
290 | 293 |
291 static VLC run_vlc[6]; | 294 static VLC run_vlc[6]; |
292 static VLC run7_vlc; | 295 static VLC run7_vlc; |
296 | |
297 static void svq3_luma_dc_dequant_idct_c(DCTELEM *block, int qp); | |
298 static void svq3_add_idct_c(uint8_t *dst, DCTELEM *block, int stride, int qp, int dc); | |
293 | 299 |
294 /** | 300 /** |
295 * fill a rectangle. | 301 * fill a rectangle. |
296 * @param h height of the recatangle, should be a constant | 302 * @param h height of the recatangle, should be a constant |
297 * @param w width of the recatangle, should be a constant | 303 * @param w width of the recatangle, should be a constant |
1674 ((uint32_t*)(src+i*stride))[2]= | 1680 ((uint32_t*)(src+i*stride))[2]= |
1675 ((uint32_t*)(src+i*stride))[3]= 0x01010101U*128U; | 1681 ((uint32_t*)(src+i*stride))[3]= 0x01010101U*128U; |
1676 } | 1682 } |
1677 } | 1683 } |
1678 | 1684 |
1679 static void pred16x16_plane_c(uint8_t *src, int stride){ | 1685 static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int svq3){ |
1680 int i, j, k; | 1686 int i, j, k; |
1681 int a; | 1687 int a; |
1682 uint8_t *cm = cropTbl + MAX_NEG_CROP; | 1688 uint8_t *cm = cropTbl + MAX_NEG_CROP; |
1683 const uint8_t * const src0 = src+7-stride; | 1689 const uint8_t * const src0 = src+7-stride; |
1684 const uint8_t *src1 = src+8*stride-1; | 1690 const uint8_t *src1 = src+8*stride-1; |
1688 for(k=2; k<=8; ++k) { | 1694 for(k=2; k<=8; ++k) { |
1689 src1 += stride; src2 -= stride; | 1695 src1 += stride; src2 -= stride; |
1690 H += k*(src0[k] - src0[-k]); | 1696 H += k*(src0[k] - src0[-k]); |
1691 V += k*(src1[0] - src2[ 0]); | 1697 V += k*(src1[0] - src2[ 0]); |
1692 } | 1698 } |
1693 H = ( 5*H+32 ) >> 6; | 1699 if(svq3){ |
1694 V = ( 5*V+32 ) >> 6; | 1700 H = ( 5*(H/4) ) / 16; |
1701 V = ( 5*(V/4) ) / 16; | |
1702 }else{ | |
1703 H = ( 5*H+32 ) >> 6; | |
1704 V = ( 5*V+32 ) >> 6; | |
1705 } | |
1695 | 1706 |
1696 a = 16*(src1[0] + src2[16] + 1) - 7*(V+H); | 1707 a = 16*(src1[0] + src2[16] + 1) - 7*(V+H); |
1697 for(j=16; j>0; --j) { | 1708 for(j=16; j>0; --j) { |
1698 int b = a; | 1709 int b = a; |
1699 a += V; | 1710 a += V; |
1704 src[19+i] = cm[ (b+3*H) >> 5 ]; | 1715 src[19+i] = cm[ (b+3*H) >> 5 ]; |
1705 b += 4*H; | 1716 b += 4*H; |
1706 } | 1717 } |
1707 src += stride; | 1718 src += stride; |
1708 } | 1719 } |
1720 } | |
1721 | |
1722 static void pred16x16_plane_c(uint8_t *src, int stride){ | |
1723 pred16x16_plane_compat_c(src, stride, 0); | |
1709 } | 1724 } |
1710 | 1725 |
1711 static void pred8x8_vertical_c(uint8_t *src, int stride){ | 1726 static void pred8x8_vertical_c(uint8_t *src, int stride){ |
1712 int i; | 1727 int i; |
1713 const uint32_t a= ((uint32_t*)(src-stride))[0]; | 1728 const uint32_t a= ((uint32_t*)(src-stride))[0]; |
2238 tr= ptr[3 - linesize]*0x01010101; | 2253 tr= ptr[3 - linesize]*0x01010101; |
2239 topright= (uint8_t*) &tr; | 2254 topright= (uint8_t*) &tr; |
2240 } | 2255 } |
2241 | 2256 |
2242 h->pred4x4[ dir ](ptr, topright, linesize); | 2257 h->pred4x4[ dir ](ptr, topright, linesize); |
2243 if(h->non_zero_count_cache[ scan8[i] ]) | 2258 if(h->non_zero_count_cache[ scan8[i] ]){ |
2244 h264_add_idct_c(ptr, h->mb + i*16, linesize); | 2259 if(s->codec_id == CODEC_ID_H264) |
2260 h264_add_idct_c(ptr, h->mb + i*16, linesize); | |
2261 else | |
2262 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, 0); | |
2263 } | |
2245 } | 2264 } |
2246 } | 2265 } |
2247 }else{ | 2266 }else{ |
2248 h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); | 2267 h->pred16x16[ h->intra16x16_pred_mode ](dest_y , linesize); |
2249 h264_luma_dc_dequant_idct_c(h->mb, s->qscale); | 2268 if(s->codec_id == CODEC_ID_H264) |
2250 } | 2269 h264_luma_dc_dequant_idct_c(h->mb, s->qscale); |
2251 }else{ | 2270 else |
2271 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); | |
2272 } | |
2273 }else if(s->codec_id == CODEC_ID_H264){ | |
2252 hl_motion(h, dest_y, dest_cb, dest_cr, | 2274 hl_motion(h, dest_y, dest_cb, dest_cr, |
2253 s->dsp.put_h264_qpel_pixels_tab, s->dsp.put_h264_chroma_pixels_tab, | 2275 s->dsp.put_h264_qpel_pixels_tab, s->dsp.put_h264_chroma_pixels_tab, |
2254 s->dsp.avg_h264_qpel_pixels_tab, s->dsp.avg_h264_chroma_pixels_tab); | 2276 s->dsp.avg_h264_qpel_pixels_tab, s->dsp.avg_h264_chroma_pixels_tab); |
2255 } | 2277 } |
2256 | 2278 |
2257 | 2279 |
2258 if(!IS_INTRA4x4(mb_type)){ | 2280 if(!IS_INTRA4x4(mb_type)){ |
2259 for(i=0; i<16; i++){ | 2281 for(i=0; i<16; i++){ |
2260 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below | 2282 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ //FIXME benchmark weird rule, & below |
2261 uint8_t * const ptr= dest_y + h->block_offset[i]; | 2283 uint8_t * const ptr= dest_y + h->block_offset[i]; |
2262 h264_add_idct_c(ptr, h->mb + i*16, linesize); | 2284 if(s->codec_id == CODEC_ID_H264) |
2285 h264_add_idct_c(ptr, h->mb + i*16, linesize); | |
2286 else | |
2287 svq3_add_idct_c(ptr, h->mb + i*16, linesize, s->qscale, IS_INTRA(mb_type) ? 1 : 0); | |
2263 } | 2288 } |
2264 } | 2289 } |
2265 } | 2290 } |
2266 | 2291 |
2267 if(!(s->flags&CODEC_FLAG_GRAY)){ | 2292 if(!(s->flags&CODEC_FLAG_GRAY)){ |
2268 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp); | 2293 chroma_dc_dequant_idct_c(h->mb + 16*16, h->chroma_qp); |
2269 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); | 2294 chroma_dc_dequant_idct_c(h->mb + 16*16+4*16, h->chroma_qp); |
2270 for(i=16; i<16+4; i++){ | 2295 for(i=16; i<16+4; i++){ |
2271 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2296 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2272 uint8_t * const ptr= dest_cb + h->block_offset[i]; | 2297 uint8_t * const ptr= dest_cb + h->block_offset[i]; |
2273 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | 2298 if(s->codec_id == CODEC_ID_H264) |
2299 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | |
2300 else | |
2301 svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2); | |
2274 } | 2302 } |
2275 } | 2303 } |
2276 for(i=20; i<20+4; i++){ | 2304 for(i=20; i<20+4; i++){ |
2277 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ | 2305 if(h->non_zero_count_cache[ scan8[i] ] || h->mb[i*16]){ |
2278 uint8_t * const ptr= dest_cr + h->block_offset[i]; | 2306 uint8_t * const ptr= dest_cr + h->block_offset[i]; |
2279 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | 2307 if(s->codec_id == CODEC_ID_H264) |
2308 h264_add_idct_c(ptr, h->mb + i*16, uvlinesize); | |
2309 else | |
2310 svq3_add_idct_c(ptr, h->mb + i*16, uvlinesize, chroma_qp[s->qscale + 12] - 12, 2); | |
2280 } | 2311 } |
2281 } | 2312 } |
2282 } | 2313 } |
2283 } | 2314 } |
2284 | 2315 |
4368 decode_end, | 4399 decode_end, |
4369 decode_frame, | 4400 decode_frame, |
4370 /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, | 4401 /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED, |
4371 }; | 4402 }; |
4372 | 4403 |
4404 #include "svq3.c" |