Revision c009df3f libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
1603 1603
    if(s->flags&CODEC_FLAG_EMU_EDGE){
1604 1604
        if(src_x<0 || src_y<0 || src_x + 17 >= s->h_edge_pos
1605 1605
                              || src_y + 17 >= s->v_edge_pos){
1606
            ff_emulated_edge_mc(s, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
1606
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, linesize, 17, 17, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
1607 1607
            ptr= s->edge_emu_buffer;
1608 1608
        }
1609 1609
    }
......
1642 1642
    if(s->flags&CODEC_FLAG_EMU_EDGE){
1643 1643
        if(src_x<0 || src_y<0 || src_x + 9 >= s->h_edge_pos>>1
1644 1644
                              || src_y + 9 >= s->v_edge_pos>>1){
1645
            ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1645
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1646 1646
            ptr= s->edge_emu_buffer;
1647 1647
            emu=1;
1648 1648
        }
......
1651 1651
    
1652 1652
    ptr = ref_picture[2] + offset;
1653 1653
    if(emu){
1654
        ff_emulated_edge_mc(s, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1654
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
1655 1655
        ptr= s->edge_emu_buffer;
1656 1656
    }
1657 1657
    s->dsp.gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, 8, motion_x&15, motion_y&15, 128 - s->no_rounding);
......
1722 1722
           s->h_edge_pos>>1, s->v_edge_pos>>1);
1723 1723
}
1724 1724

  
1725

  
1726
void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h, 
1725
/**
1726
 * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples.
1727
 * @param buf destination buffer
1728
 * @param src source buffer
1729
 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
1730
 * @param block_w width of block
1731
 * @param block_h height of block
1732
 * @param src_x x coordinate of the top left sample of the block in the source buffer
1733
 * @param src_y y coordinate of the top left sample of the block in the source buffer
1734
 * @param w width of the source buffer
1735
 * @param h height of the source buffer
1736
 */
1737
void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, 
1727 1738
                                    int src_x, int src_y, int w, int h){
1728 1739
    int x, y;
1729 1740
    int start_y, start_x, end_y, end_x;
1730
    uint8_t *buf= s->edge_emu_buffer;
1731 1741

  
1732 1742
    if(src_y>= h){
1733 1743
        src+= (h-1-src_y)*linesize;
......
1823 1833
    if(s->flags&CODEC_FLAG_EMU_EDGE){
1824 1834
        if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 16 > s->h_edge_pos
1825 1835
                              || src_y + (motion_y&1) + h  > v_edge_pos){
1826
            ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based,  //FIXME linesize? and uv below
1836
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr - src_offset, s->linesize, 17, 17+field_based,  //FIXME linesize? and uv below
1827 1837
                             src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
1828 1838
            ptr= s->edge_emu_buffer + src_offset;
1829 1839
            emu=1;
......
1860 1870
    offset = (src_y * uvlinesize) + src_x + (src_offset >> 1);
1861 1871
    ptr = ref_picture[1] + offset;
1862 1872
    if(emu){
1863
        ff_emulated_edge_mc(s, ptr - (src_offset >> 1), s->uvlinesize, 9, 9+field_based, 
1873
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr - (src_offset >> 1), s->uvlinesize, 9, 9+field_based, 
1864 1874
                         src_x, src_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
1865 1875
        ptr= s->edge_emu_buffer + (src_offset >> 1);
1866 1876
    }
......
1868 1878

  
1869 1879
    ptr = ref_picture[2] + offset;
1870 1880
    if(emu){
1871
        ff_emulated_edge_mc(s, ptr - (src_offset >> 1), s->uvlinesize, 9, 9+field_based, 
1881
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr - (src_offset >> 1), s->uvlinesize, 9, 9+field_based, 
1872 1882
                         src_x, src_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
1873 1883
        ptr= s->edge_emu_buffer + (src_offset >> 1);
1874 1884
    }
......
1908 1918
    if(s->flags&CODEC_FLAG_EMU_EDGE){
1909 1919
        if(src_x<0 || src_y<0 || src_x + (motion_x&3) + 16 > s->h_edge_pos
1910 1920
                              || src_y + (motion_y&3) + h  > v_edge_pos){
1911
            ff_emulated_edge_mc(s, ptr - src_offset, s->linesize, 17, 17+field_based, 
1921
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr - src_offset, s->linesize, 17, 17+field_based, 
1912 1922
                             src_x, src_y<<field_based, s->h_edge_pos, s->v_edge_pos);
1913 1923
            ptr= s->edge_emu_buffer + src_offset;
1914 1924
            emu=1;
......
1958 1968
    offset = (src_y * uvlinesize) + src_x + (src_offset >> 1);
1959 1969
    ptr = ref_picture[1] + offset;
1960 1970
    if(emu){
1961
        ff_emulated_edge_mc(s, ptr - (src_offset >> 1), s->uvlinesize, 9, 9 + field_based, 
1971
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr - (src_offset >> 1), s->uvlinesize, 9, 9 + field_based, 
1962 1972
                         src_x, src_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
1963 1973
        ptr= s->edge_emu_buffer + (src_offset >> 1);
1964 1974
    }
......
1966 1976
    
1967 1977
    ptr = ref_picture[2] + offset;
1968 1978
    if(emu){
1969
        ff_emulated_edge_mc(s, ptr - (src_offset >> 1), s->uvlinesize, 9, 9 + field_based, 
1979
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr - (src_offset >> 1), s->uvlinesize, 9, 9 + field_based, 
1970 1980
                         src_x, src_y<<field_based, s->h_edge_pos>>1, s->v_edge_pos>>1);
1971 1981
        ptr= s->edge_emu_buffer + (src_offset >> 1);
1972 1982
    }
......
2060 2070
                if(s->flags&CODEC_FLAG_EMU_EDGE){
2061 2071
                    if(src_x<0 || src_y<0 || src_x + (motion_x&3) + 8 > s->h_edge_pos
2062 2072
                                          || src_y + (motion_y&3) + 8 > s->v_edge_pos){
2063
                        ff_emulated_edge_mc(s, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
2073
                        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
2064 2074
                        ptr= s->edge_emu_buffer;
2065 2075
                    }
2066 2076
                }
......
2091 2101
                if(s->flags&CODEC_FLAG_EMU_EDGE){
2092 2102
                    if(src_x<0 || src_y<0 || src_x + (motion_x&1) + 8 > s->h_edge_pos
2093 2103
                                          || src_y + (motion_y&1) + 8 > s->v_edge_pos){
2094
                        ff_emulated_edge_mc(s, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
2104
                        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos);
2095 2105
                        ptr= s->edge_emu_buffer;
2096 2106
                    }
2097 2107
                }
......
2126 2136
        if(s->flags&CODEC_FLAG_EMU_EDGE){
2127 2137
                if(src_x<0 || src_y<0 || src_x + (dxy &1) + 8 > s->h_edge_pos>>1
2128 2138
                                      || src_y + (dxy>>1) + 8 > s->v_edge_pos>>1){
2129
                    ff_emulated_edge_mc(s, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
2139
                    ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
2130 2140
                    ptr= s->edge_emu_buffer;
2131 2141
                    emu=1;
2132 2142
                }
......
2135 2145

  
2136 2146
        ptr = ref_picture[2] + offset;
2137 2147
        if(emu){
2138
            ff_emulated_edge_mc(s, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
2148
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
2139 2149
            ptr= s->edge_emu_buffer;
2140 2150
        }
2141 2151
        pix_op[1][dxy](dest_cr, ptr, s->uvlinesize, 8);
......
2674 2684
        ptr = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
2675 2685

  
2676 2686
        if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
2677
            ff_emulated_edge_mc(s, ptr, wrap_y, 16, 16, mb_x*16, mb_y*16, s->width, s->height);
2687
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr, wrap_y, 16, 16, mb_x*16, mb_y*16, s->width, s->height);
2678 2688
            ptr= s->edge_emu_buffer;
2679 2689
            emu=1;
2680 2690
        }
......
2706 2716
            int wrap_c = s->uvlinesize;
2707 2717
            ptr = s->new_picture.data[1] + (mb_y * 8 * wrap_c) + mb_x * 8;
2708 2718
            if(emu){
2709
                ff_emulated_edge_mc(s, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2719
                ff_emulated_edge_mc(s->edge_emu_buffer, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2710 2720
                ptr= s->edge_emu_buffer;
2711 2721
            }
2712 2722
	    s->dsp.get_pixels(s->block[4], ptr, wrap_c);
2713 2723

  
2714 2724
            ptr = s->new_picture.data[2] + (mb_y * 8 * wrap_c) + mb_x * 8;
2715 2725
            if(emu){
2716
                ff_emulated_edge_mc(s, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2726
                ff_emulated_edge_mc(s->edge_emu_buffer, ptr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2717 2727
                ptr= s->edge_emu_buffer;
2718 2728
            }
2719 2729
            s->dsp.get_pixels(s->block[5], ptr, wrap_c);
......
2753 2763
        }
2754 2764

  
2755 2765
        if(mb_x*16+16 > s->width || mb_y*16+16 > s->height){
2756
            ff_emulated_edge_mc(s, ptr_y, wrap_y, 16, 16, mb_x*16, mb_y*16, s->width, s->height);
2766
            ff_emulated_edge_mc(s->edge_emu_buffer, ptr_y, wrap_y, 16, 16, mb_x*16, mb_y*16, s->width, s->height);
2757 2767
            ptr_y= s->edge_emu_buffer;
2758 2768
            emu=1;
2759 2769
        }
......
2785 2795
            skip_dct[5]= 1;
2786 2796
        }else{
2787 2797
            if(emu){
2788
                ff_emulated_edge_mc(s, ptr_cb, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2798
                ff_emulated_edge_mc(s->edge_emu_buffer, ptr_cb, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2789 2799
                ptr_cb= s->edge_emu_buffer;
2790 2800
            }
2791 2801
            s->dsp.diff_pixels(s->block[4], ptr_cb, dest_cb, wrap_c);
2792 2802
            if(emu){
2793
                ff_emulated_edge_mc(s, ptr_cr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2803
                ff_emulated_edge_mc(s->edge_emu_buffer, ptr_cr, wrap_c, 8, 8, mb_x*8, mb_y*8, s->width>>1, s->height>>1);
2794 2804
                ptr_cr= s->edge_emu_buffer;
2795 2805
            }
2796 2806
            s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);

Also available in: Unified diff