comparison mpeg12.c @ 1891:f403b3e286b3 libavcodec

use pan_scan to remove some weight, proper pan_scan offset reading
author iive
date Tue, 16 Mar 2004 15:38:40 +0000
parents a07406ac4725
children 5ac49e7a1b8f
comparison
equal deleted inserted replaced
1890:a07406ac4725 1891:f403b3e286b3
1748 1748
1749 typedef struct Mpeg1Context { 1749 typedef struct Mpeg1Context {
1750 MpegEncContext mpeg_enc_ctx; 1750 MpegEncContext mpeg_enc_ctx;
1751 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ 1751 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
1752 int repeat_field; /* true if we must repeat the field */ 1752 int repeat_field; /* true if we must repeat the field */
1753 int display_weight;
1754 int display_height;
1755 AVPanScan pan_scan; /** some temporary storage for the panscan */ 1753 AVPanScan pan_scan; /** some temporary storage for the panscan */
1756 int slice_count; 1754 int slice_count;
1757 int swap_uv;//indicate VCR2 1755 int swap_uv;//indicate VCR2
1758 int save_aspect_info; 1756 int save_aspect_info;
1759 1757
1836 frame_rate_tab[s->frame_rate_index].num * (s->frame_rate_ext_n+1), 1834 frame_rate_tab[s->frame_rate_index].num * (s->frame_rate_ext_n+1),
1837 frame_rate_tab[s->frame_rate_index].den * (s->frame_rate_ext_d+1), 1835 frame_rate_tab[s->frame_rate_index].den * (s->frame_rate_ext_d+1),
1838 1<<30); 1836 1<<30);
1839 //mpeg2 aspect 1837 //mpeg2 aspect
1840 if(s->aspect_ratio_info > 1){ 1838 if(s->aspect_ratio_info > 1){
1841 if( (s1->display_weight == 0 )||(s1->display_height == 0) ){ 1839 if( (s1->pan_scan.width == 0 )||(s1->pan_scan.height == 0) ){
1842 s->avctx->sample_aspect_ratio= 1840 s->avctx->sample_aspect_ratio=
1843 av_div_q( 1841 av_div_q(
1844 mpeg2_aspect[s->aspect_ratio_info], 1842 mpeg2_aspect[s->aspect_ratio_info],
1845 (AVRational){s->width, s->height} 1843 (AVRational){s->width, s->height}
1846 ); 1844 );
1847 }else{ 1845 }else{
1848 s->avctx->sample_aspect_ratio= 1846 s->avctx->sample_aspect_ratio=
1849 av_div_q( 1847 av_div_q(
1850 mpeg2_aspect[s->aspect_ratio_info], 1848 mpeg2_aspect[s->aspect_ratio_info],
1851 (AVRational){s1->display_weight, s1->display_height} 1849 (AVRational){s1->pan_scan.width, s1->pan_scan.height}
1852 ); 1850 );
1853 } 1851 }
1854 }else{ 1852 }else{
1855 s->avctx->sample_aspect_ratio= 1853 s->avctx->sample_aspect_ratio=
1856 mpeg2_aspect[s->aspect_ratio_info]; 1854 mpeg2_aspect[s->aspect_ratio_info];
2016 h= get_bits(&s->gb, 14); 2014 h= get_bits(&s->gb, 14);
2017 skip_bits(&s->gb, 1); //marker 2015 skip_bits(&s->gb, 1); //marker
2018 2016
2019 s1->pan_scan.width= 16*w; 2017 s1->pan_scan.width= 16*w;
2020 s1->pan_scan.height=16*h; 2018 s1->pan_scan.height=16*h;
2021 2019
2022 s1->display_weight = w;
2023 s1->display_height = h;
2024
2025
2026 if(s->avctx->debug & FF_DEBUG_PICT_INFO) 2020 if(s->avctx->debug & FF_DEBUG_PICT_INFO)
2027 av_log(s->avctx, AV_LOG_DEBUG, "sde w:%d, h:%d\n", w, h); 2021 av_log(s->avctx, AV_LOG_DEBUG, "sde w:%d, h:%d\n", w, h);
2028 } 2022 }
2029 2023
2030 static void mpeg_decode_picture_display_extension(Mpeg1Context *s1) 2024 static void mpeg_decode_picture_display_extension(Mpeg1Context *s1)
2031 { 2025 {
2032 MpegEncContext *s= &s1->mpeg_enc_ctx; 2026 MpegEncContext *s= &s1->mpeg_enc_ctx;
2033 int i; 2027 int i,nofco;
2034 2028
2035 for(i=0; i<1; i++){ //FIXME count 2029 nofco = 1;
2030 if(s->progressive_sequence){
2031 if(s->repeat_first_field){
2032 nofco++;
2033 if(s->top_field_first)
2034 nofco++;
2035 }
2036 }else{
2037 if(s->picture_structure == PICT_FRAME){
2038 nofco++;
2039 if(s->repeat_first_field)
2040 nofco++;
2041 }
2042 }
2043 for(i=0; i<nofco; i++){
2036 s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16); 2044 s1->pan_scan.position[i][0]= get_sbits(&s->gb, 16);
2037 skip_bits(&s->gb, 1); //marker 2045 skip_bits(&s->gb, 1); //marker
2038 s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16); 2046 s1->pan_scan.position[i][1]= get_sbits(&s->gb, 16);
2039 skip_bits(&s->gb, 1); //marker 2047 skip_bits(&s->gb, 1); //marker
2040 } 2048 }