Mercurial > libavcodec.hg
comparison mpeg12.c @ 1546:5d06823e2ee9 libavcodec
export mpeg2 active display area / pan scan
fix mpeg2 aspect_ratio for the rare case that active display area != AVCodecContext.width/height
decode sequence display extension & picture display extension
author | michael |
---|---|
date | Mon, 20 Oct 2003 09:52:02 +0000 |
parents | 3b31998fe22f |
children | dd544554ed42 |
comparison
equal
deleted
inserted
replaced
1545:b340e83b8d0d | 1546:5d06823e2ee9 |
---|---|
1653 | 1653 |
1654 typedef struct Mpeg1Context { | 1654 typedef struct Mpeg1Context { |
1655 MpegEncContext mpeg_enc_ctx; | 1655 MpegEncContext mpeg_enc_ctx; |
1656 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ | 1656 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ |
1657 int repeat_field; /* true if we must repeat the field */ | 1657 int repeat_field; /* true if we must repeat the field */ |
1658 AVPanScan pan_scan; /** some temporary storage for the panscan */ | |
1658 } Mpeg1Context; | 1659 } Mpeg1Context; |
1659 | 1660 |
1660 static int mpeg_decode_init(AVCodecContext *avctx) | 1661 static int mpeg_decode_init(AVCodecContext *avctx) |
1661 { | 1662 { |
1662 Mpeg1Context *s = avctx->priv_data; | 1663 Mpeg1Context *s = avctx->priv_data; |
1777 if(aspect>0.0) s->avctx->aspect_ratio= s->width/(aspect*s->height); | 1778 if(aspect>0.0) s->avctx->aspect_ratio= s->width/(aspect*s->height); |
1778 else if(aspect<0.0) s->avctx->aspect_ratio= -1.0/aspect; | 1779 else if(aspect<0.0) s->avctx->aspect_ratio= -1.0/aspect; |
1779 | 1780 |
1780 if(s->avctx->debug & FF_DEBUG_PICT_INFO) | 1781 if(s->avctx->debug & FF_DEBUG_PICT_INFO) |
1781 printf("profile: %d, level: %d \n", profile, level); | 1782 printf("profile: %d, level: %d \n", profile, level); |
1783 } | |
1784 | |
1785 static void mpeg_decode_sequence_display_extension(Mpeg1Context *s1) | |
1786 { | |
1787 MpegEncContext *s= &s1->mpeg_enc_ctx; | |
1788 int color_description, w, h; | |
1789 | |
1790 skip_bits(&s->gb, 3); /* video format */ | |
1791 color_description= get_bits1(&s->gb); | |
1792 if(color_description){ | |
1793 skip_bits(&s->gb, 8); /* color primaries */ | |
1794 skip_bits(&s->gb, 8); /* transfer_characteristics */ | |
1795 skip_bits(&s->gb, 8); /* matrix_coefficients */ | |
1796 } | |
1797 w= get_bits(&s->gb, 14); | |
1798 skip_bits(&s->gb, 1); //marker | |
1799 h= get_bits(&s->gb, 14); | |
1800 skip_bits(&s->gb, 1); //marker | |
1801 | |
1802 s1->pan_scan.width= 16*w; | |
1803 s1->pan_scan.height=16*h; | |
1804 | |
1805 if(mpeg2_aspect[s->aspect_ratio_info] < 0.0) | |
1806 s->avctx->aspect_ratio*= (s->width * h)/(float)(s->height * w); | |
1807 | |
1808 if(s->avctx->debug & FF_DEBUG_PICT_INFO) | |
1809 printf("sde w:%d, h:%d\n", w, h); | |
1810 } | |
1811 | |
1812 static void mpeg_decode_picture_display_extension(Mpeg1Context *s1) | |
1813 { | |
1814 MpegEncContext *s= &s1->mpeg_enc_ctx; | |
1815 int i; | |
1816 | |
1817 for(i=0; i<1; i++){ //FIXME count | |
1818 s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16); | |
1819 skip_bits(&s->gb, 1); //marker | |
1820 s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16); | |
1821 skip_bits(&s->gb, 1); //marker | |
1822 } | |
1823 | |
1824 if(s->avctx->debug & FF_DEBUG_PICT_INFO) | |
1825 printf("pde (%d,%d) (%d,%d) (%d,%d)\n", | |
1826 s1->pan_scan.position[0][0], s1->pan_scan.position[0][1], | |
1827 s1->pan_scan.position[1][0], s1->pan_scan.position[1][1], | |
1828 s1->pan_scan.position[2][0], s1->pan_scan.position[2][1] | |
1829 ); | |
1782 } | 1830 } |
1783 | 1831 |
1784 static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) | 1832 static void mpeg_decode_quant_matrix_extension(MpegEncContext *s) |
1785 { | 1833 { |
1786 int i, v, j; | 1834 int i, v, j; |
1879 init_get_bits(&s->gb, buf, buf_size*8); | 1927 init_get_bits(&s->gb, buf, buf_size*8); |
1880 | 1928 |
1881 ext_type = get_bits(&s->gb, 4); | 1929 ext_type = get_bits(&s->gb, 4); |
1882 switch(ext_type) { | 1930 switch(ext_type) { |
1883 case 0x1: | 1931 case 0x1: |
1884 /* sequence ext */ | |
1885 mpeg_decode_sequence_extension(s); | 1932 mpeg_decode_sequence_extension(s); |
1886 break; | 1933 break; |
1934 case 0x2: | |
1935 mpeg_decode_sequence_display_extension(s1); | |
1936 break; | |
1887 case 0x3: | 1937 case 0x3: |
1888 /* quant matrix extension */ | |
1889 mpeg_decode_quant_matrix_extension(s); | 1938 mpeg_decode_quant_matrix_extension(s); |
1890 break; | 1939 break; |
1940 case 0x7: | |
1941 mpeg_decode_picture_display_extension(s1); | |
1942 break; | |
1891 case 0x8: | 1943 case 0x8: |
1892 /* picture extension */ | |
1893 mpeg_decode_picture_coding_extension(s); | 1944 mpeg_decode_picture_coding_extension(s); |
1894 break; | 1945 break; |
1895 } | 1946 } |
1896 } | 1947 } |
1897 | 1948 |
1951 s->current_picture_ptr->repeat_pict = 2; | 2002 s->current_picture_ptr->repeat_pict = 2; |
1952 } else if (s->progressive_frame) { | 2003 } else if (s->progressive_frame) { |
1953 s->current_picture_ptr->repeat_pict = 1; | 2004 s->current_picture_ptr->repeat_pict = 1; |
1954 } | 2005 } |
1955 } | 2006 } |
2007 | |
2008 *s->current_picture_ptr->pan_scan= s1->pan_scan; | |
2009 | |
1956 //printf("%d\n", s->current_picture_ptr->repeat_pict); | 2010 //printf("%d\n", s->current_picture_ptr->repeat_pict); |
1957 | 2011 |
1958 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ | 2012 if(s->avctx->debug&FF_DEBUG_PICT_INFO){ |
1959 printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", | 2013 printf("qp:%d fc:%2d%2d%2d%2d %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", |
1960 s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], | 2014 s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], |