Mercurial > libavcodec.hg
comparison mpegvideo.c @ 2395:81516be6d0e4 libavcodec
vismv for h264 displayed incorrect motion vectors.
author | lorenm |
---|---|
date | Mon, 20 Dec 2004 03:03:37 +0000 |
parents | ce45e1dd4b09 |
children | 0c5ceb97815d |
comparison
equal
deleted
inserted
replaced
2394:776e37360171 | 2395:81516be6d0e4 |
---|---|
1760 uint8_t *ptr; | 1760 uint8_t *ptr; |
1761 int i; | 1761 int i; |
1762 int h_chroma_shift, v_chroma_shift; | 1762 int h_chroma_shift, v_chroma_shift; |
1763 const int width = s->avctx->width; | 1763 const int width = s->avctx->width; |
1764 const int height= s->avctx->height; | 1764 const int height= s->avctx->height; |
1765 const int mv_sample_log2= 4 - pict->motion_subsample_log2; | |
1766 const int mv_stride= (s->mb_width << mv_sample_log2) + 1; | |
1765 s->low_delay=0; //needed to see the vectors without trashing the buffers | 1767 s->low_delay=0; //needed to see the vectors without trashing the buffers |
1766 | 1768 |
1767 avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift); | 1769 avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift); |
1768 for(i=0; i<3; i++){ | 1770 for(i=0; i<3; i++){ |
1769 memcpy(s->visualization_buffer[i], pict->data[i], (i==0) ? pict->linesize[i]*height:pict->linesize[i]*height >> v_chroma_shift); | 1771 memcpy(s->visualization_buffer[i], pict->data[i], (i==0) ? pict->linesize[i]*height:pict->linesize[i]*height >> v_chroma_shift); |
1795 break; | 1797 break; |
1796 } | 1798 } |
1797 if(!USES_LIST(pict->mb_type[mb_index], direction)) | 1799 if(!USES_LIST(pict->mb_type[mb_index], direction)) |
1798 continue; | 1800 continue; |
1799 | 1801 |
1800 //FIXME for h264 | |
1801 if(IS_8X8(pict->mb_type[mb_index])){ | 1802 if(IS_8X8(pict->mb_type[mb_index])){ |
1802 int i; | 1803 int i; |
1803 for(i=0; i<4; i++){ | 1804 for(i=0; i<4; i++){ |
1804 int sx= mb_x*16 + 4 + 8*(i&1); | 1805 int sx= mb_x*16 + 4 + 8*(i&1); |
1805 int sy= mb_y*16 + 4 + 8*(i>>1); | 1806 int sy= mb_y*16 + 4 + 8*(i>>1); |
1806 int xy= mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride; | 1807 int xy= (mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*mv_stride) << mv_sample_log2-1; |
1807 int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; | 1808 int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; |
1808 int my= (pict->motion_val[direction][xy][1]>>shift) + sy; | 1809 int my= (pict->motion_val[direction][xy][1]>>shift) + sy; |
1809 draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); | 1810 draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); |
1810 } | 1811 } |
1811 }else if(IS_16X8(pict->mb_type[mb_index])){ | 1812 }else if(IS_16X8(pict->mb_type[mb_index])){ |
1812 int i; | 1813 int i; |
1813 for(i=0; i<2; i++){ | 1814 for(i=0; i<2; i++){ |
1814 int sx=mb_x*16 + 8; | 1815 int sx=mb_x*16 + 8; |
1815 int sy=mb_y*16 + 4 + 8*i; | 1816 int sy=mb_y*16 + 4 + 8*i; |
1816 int xy= mb_x*2 + (mb_y*2 + i)*s->b8_stride; | 1817 int xy= (mb_x*2 + (mb_y*2 + i)*mv_stride) << mv_sample_log2-1; |
1818 int mx=(pict->motion_val[direction][xy][0]>>shift); | |
1819 int my=(pict->motion_val[direction][xy][1]>>shift); | |
1820 | |
1821 if(IS_INTERLACED(pict->mb_type[mb_index])) | |
1822 my*=2; | |
1823 | |
1824 draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100); | |
1825 } | |
1826 }else if(IS_8X16(pict->mb_type[mb_index])){ | |
1827 int i; | |
1828 for(i=0; i<2; i++){ | |
1829 int sx=mb_x*16 + 4 + 8*i; | |
1830 int sy=mb_y*16 + 8; | |
1831 int xy= (mb_x*2 + i + mb_y*2*mv_stride) << mv_sample_log2-1; | |
1817 int mx=(pict->motion_val[direction][xy][0]>>shift); | 1832 int mx=(pict->motion_val[direction][xy][0]>>shift); |
1818 int my=(pict->motion_val[direction][xy][1]>>shift); | 1833 int my=(pict->motion_val[direction][xy][1]>>shift); |
1819 | 1834 |
1820 if(IS_INTERLACED(pict->mb_type[mb_index])) | 1835 if(IS_INTERLACED(pict->mb_type[mb_index])) |
1821 my*=2; | 1836 my*=2; |
1823 draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100); | 1838 draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100); |
1824 } | 1839 } |
1825 }else{ | 1840 }else{ |
1826 int sx= mb_x*16 + 8; | 1841 int sx= mb_x*16 + 8; |
1827 int sy= mb_y*16 + 8; | 1842 int sy= mb_y*16 + 8; |
1828 int xy= mb_x*2 + mb_y*2*s->b8_stride; | 1843 int xy= (mb_x + mb_y*mv_stride) << mv_sample_log2; |
1829 int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; | 1844 int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; |
1830 int my= (pict->motion_val[direction][xy][1]>>shift) + sy; | 1845 int my= (pict->motion_val[direction][xy][1]>>shift) + sy; |
1831 draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); | 1846 draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); |
1832 } | 1847 } |
1833 } | 1848 } |