Mercurial > libavcodec.hg
comparison h264.c @ 4269:c37ea749711e libavcodec
Removing unused code
author | takis |
---|---|
date | Tue, 05 Dec 2006 22:05:09 +0000 |
parents | 6f839bb47457 |
children | 758ba4a18478 |
comparison
equal
deleted
inserted
replaced
4268:3a4d4be05618 | 4269:c37ea749711e |
---|---|
1792 *consumed= si + 1;//+1 for the header | 1792 *consumed= si + 1;//+1 for the header |
1793 //FIXME store exact number of bits in the getbitcontext (its needed for decoding) | 1793 //FIXME store exact number of bits in the getbitcontext (its needed for decoding) |
1794 return dst; | 1794 return dst; |
1795 } | 1795 } |
1796 | 1796 |
1797 #if 0 | |
1798 /** | |
1799 * @param src the data which should be escaped | |
1800 * @param dst the target buffer, dst+1 == src is allowed as a special case | |
1801 * @param length the length of the src data | |
1802 * @param dst_length the length of the dst array | |
1803 * @returns length of escaped data in bytes or -1 if an error occured | |
1804 */ | |
1805 static int encode_nal(H264Context *h, uint8_t *dst, uint8_t *src, int length, int dst_length){ | |
1806 int i, escape_count, si, di; | |
1807 uint8_t *temp; | |
1808 | |
1809 assert(length>=0); | |
1810 assert(dst_length>0); | |
1811 | |
1812 dst[0]= (h->nal_ref_idc<<5) + h->nal_unit_type; | |
1813 | |
1814 if(length==0) return 1; | |
1815 | |
1816 escape_count= 0; | |
1817 for(i=0; i<length; i+=2){ | |
1818 if(src[i]) continue; | |
1819 if(i>0 && src[i-1]==0) | |
1820 i--; | |
1821 if(i+2<length && src[i+1]==0 && src[i+2]<=3){ | |
1822 escape_count++; | |
1823 i+=2; | |
1824 } | |
1825 } | |
1826 | |
1827 if(escape_count==0){ | |
1828 if(dst+1 != src) | |
1829 memcpy(dst+1, src, length); | |
1830 return length + 1; | |
1831 } | |
1832 | |
1833 if(length + escape_count + 1> dst_length) | |
1834 return -1; | |
1835 | |
1836 //this should be damn rare (hopefully) | |
1837 | |
1838 h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length + escape_count); | |
1839 temp= h->rbsp_buffer; | |
1840 //printf("encoding esc\n"); | |
1841 | |
1842 si= 0; | |
1843 di= 0; | |
1844 while(si < length){ | |
1845 if(si+2<length && src[si]==0 && src[si+1]==0 && src[si+2]<=3){ | |
1846 temp[di++]= 0; si++; | |
1847 temp[di++]= 0; si++; | |
1848 temp[di++]= 3; | |
1849 temp[di++]= src[si++]; | |
1850 } | |
1851 else | |
1852 temp[di++]= src[si++]; | |
1853 } | |
1854 memcpy(dst+1, temp, length+escape_count); | |
1855 | |
1856 assert(di == length+escape_count); | |
1857 | |
1858 return di + 1; | |
1859 } | |
1860 | |
1861 /** | |
1862 * write 1,10,100,1000,... for alignment, yes its exactly inverse to mpeg4 | |
1863 */ | |
1864 static void encode_rbsp_trailing(PutBitContext *pb){ | |
1865 int length; | |
1866 put_bits(pb, 1, 1); | |
1867 length= (-put_bits_count(pb))&7; | |
1868 if(length) put_bits(pb, length, 0); | |
1869 } | |
1870 #endif | |
1871 | |
1872 /** | 1797 /** |
1873 * identifies the exact end of the bitstream | 1798 * identifies the exact end of the bitstream |
1874 * @return the length of the trailing, or 0 if damaged | 1799 * @return the length of the trailing, or 0 if damaged |
1875 */ | 1800 */ |
1876 static int decode_rbsp_trailing(uint8_t *src){ | 1801 static int decode_rbsp_trailing(uint8_t *src){ |