Revision c009df3f

View differences:

libavcodec/h264.c
1895 1895
       || full_my < 0-extra_height 
1896 1896
       || full_mx + 16/*FIXME*/ > s->width + extra_width 
1897 1897
       || full_my + 16/*FIXME*/ > s->height + extra_height){
1898
        ff_emulated_edge_mc(s, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, s->width, s->height);
1898
        ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, s->width, s->height);
1899 1899
            src_y= s->edge_emu_buffer + 2 + 2*s->linesize;
1900 1900
        emu=1;
1901 1901
    }
......
1908 1908
    if(s->flags&CODEC_FLAG_GRAY) return;
1909 1909
    
1910 1910
    if(emu){
1911
        ff_emulated_edge_mc(s, src_cb, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1);
1911
        ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1);
1912 1912
            src_cb= s->edge_emu_buffer;
1913 1913
    }
1914 1914
    chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7);
1915 1915

  
1916 1916
    if(emu){
1917
        ff_emulated_edge_mc(s, src_cr, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1);
1917
        ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), s->width>>1, s->height>>1);
1918 1918
            src_cr= s->edge_emu_buffer;
1919 1919
    }
1920 1920
    chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7);
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);
libavcodec/mpegvideo.h
708 708
void ff_clean_intra_table_entries(MpegEncContext *s);
709 709
void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
710 710
void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
711
void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h, 
711
void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, 
712 712
                                    int src_x, int src_y, int w, int h);
713 713
#define END_NOT_FOUND -100
714 714
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
......
877 877
                       DCTELEM block[6][64],
878 878
                       int motion_x, int motion_y);
879 879

  
880
/* mjpegenc.c */
880
/* mjpeg.c */
881 881
int mjpeg_init(MpegEncContext *s);
882 882
void mjpeg_close(MpegEncContext *s);
883 883
void mjpeg_encode_mb(MpegEncContext *s, 
libavcodec/svq3.c
287 287
  src  = s->last_picture.data[0] + mx + my*s->linesize;
288 288

  
289 289
  if (emu) {
290
    ff_emulated_edge_mc (s, src, s->linesize, (width + 1), (height + 1),
290
    ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, (width + 1), (height + 1),
291 291
			 mx, my, s->h_edge_pos, s->v_edge_pos);
292 292
    src = s->edge_emu_buffer;
293 293
  }
......
308 308
      src  = s->last_picture.data[i] + mx + my*s->uvlinesize;
309 309

  
310 310
      if (emu) {
311
	ff_emulated_edge_mc (s, src, s->uvlinesize, (width + 1), (height + 1),
311
	ff_emulated_edge_mc(s->edge_emu_buffer, src, s->uvlinesize, (width + 1), (height + 1),
312 312
			     mx, my, (s->h_edge_pos >> 1), (s->v_edge_pos >> 1));
313 313
	src = s->edge_emu_buffer;
314 314
      }
libavcodec/wmv2.c
650 650
    if(s->flags&CODEC_FLAG_EMU_EDGE){
651 651
        if(src_x<1 || src_y<1 || src_x + 17  >= s->h_edge_pos
652 652
                              || src_y + h+1 >= v_edge_pos){
653
            ff_emulated_edge_mc(s, ptr - 1 - s->linesize, s->linesize, 19, 19, 
653
            ff_emulated_edge_mc(s->emu_edge_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19, 
654 654
                             src_x-1, src_y-1, s->h_edge_pos, s->v_edge_pos);
655 655
            ptr= s->edge_emu_buffer + 1 + s->linesize;
656 656
            emu=1;
......
691 691
    offset = (src_y * uvlinesize) + src_x;
692 692
    ptr = ref_picture[1] + offset;
693 693
    if(emu){
694
        ff_emulated_edge_mc(s, ptr, s->uvlinesize, 9, 9, 
694
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, 
695 695
                         src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
696 696
        ptr= s->edge_emu_buffer;
697 697
    }
......
699 699

  
700 700
    ptr = ref_picture[2] + offset;
701 701
    if(emu){
702
        ff_emulated_edge_mc(s, ptr, s->uvlinesize, 9, 9, 
702
        ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, 
703 703
                         src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
704 704
        ptr= s->edge_emu_buffer;
705 705
    }

Also available in: Unified diff