comparison h264.c @ 1548:dd544554ed42 libavcodec

AVRational sample_aspect_ratio aspect ratio in JPEG JFIF is SAR not DAR ! removed nonsense SAR guessing code various related cleanups bugs?
author michael
date Mon, 20 Oct 2003 20:23:46 +0000
parents 7f9f0bedc2e1
children 932d306bf1dc
comparison
equal deleted inserted replaced
1547:0183874861fd 1548:dd544554ed42
77 int crop_left; ///< frame_cropping_rect_left_offset 77 int crop_left; ///< frame_cropping_rect_left_offset
78 int crop_right; ///< frame_cropping_rect_right_offset 78 int crop_right; ///< frame_cropping_rect_right_offset
79 int crop_top; ///< frame_cropping_rect_top_offset 79 int crop_top; ///< frame_cropping_rect_top_offset
80 int crop_bottom; ///< frame_cropping_rect_bottom_offset 80 int crop_bottom; ///< frame_cropping_rect_bottom_offset
81 int vui_parameters_present_flag; 81 int vui_parameters_present_flag;
82 int sar_width; 82 AVRational sar;
83 int sar_height;
84 short offset_for_ref_frame[256]; //FIXME dyn aloc? 83 short offset_for_ref_frame[256]; //FIXME dyn aloc?
85 }SPS; 84 }SPS;
86 85
87 /** 86 /**
88 * Picture parameter set 87 * Picture parameter set
2827 static int decode_slice_header(H264Context *h){ 2826 static int decode_slice_header(H264Context *h){
2828 MpegEncContext * const s = &h->s; 2827 MpegEncContext * const s = &h->s;
2829 int first_mb_in_slice, pps_id; 2828 int first_mb_in_slice, pps_id;
2830 int num_ref_idx_active_override_flag; 2829 int num_ref_idx_active_override_flag;
2831 static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE}; 2830 static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
2832 float new_aspect;
2833 2831
2834 s->current_picture.reference= h->nal_ref_idc != 0; 2832 s->current_picture.reference= h->nal_ref_idc != 0;
2835 2833
2836 first_mb_in_slice= get_ue_golomb(&s->gb); 2834 first_mb_in_slice= get_ue_golomb(&s->gb);
2837 2835
2879 if(h->sps.frame_mbs_only_flag) 2877 if(h->sps.frame_mbs_only_flag)
2880 s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom); 2878 s->height= 16*s->mb_height - 2*(h->sps.crop_top + h->sps.crop_bottom);
2881 else 2879 else
2882 s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck 2880 s->height= 16*s->mb_height - 4*(h->sps.crop_top + h->sps.crop_bottom); //FIXME recheck
2883 2881
2884 if(s->aspected_height) //FIXME emms at end of slice ?
2885 new_aspect= h->sps.sar_width*s->width / (float)(s->height*h->sps.sar_height);
2886 else
2887 new_aspect=0;
2888
2889 if (s->context_initialized 2882 if (s->context_initialized
2890 && ( s->width != s->avctx->width || s->height != s->avctx->height 2883 && ( s->width != s->avctx->width || s->height != s->avctx->height)) {
2891 || ABS(new_aspect - s->avctx->aspect_ratio) > 0.001)) {
2892 free_tables(h); 2884 free_tables(h);
2893 MPV_common_end(s); 2885 MPV_common_end(s);
2894 } 2886 }
2895 if (!s->context_initialized) { 2887 if (!s->context_initialized) {
2896 if (MPV_common_init(s) < 0) 2888 if (MPV_common_init(s) < 0)
2898 2890
2899 alloc_tables(h); 2891 alloc_tables(h);
2900 2892
2901 s->avctx->width = s->width; 2893 s->avctx->width = s->width;
2902 s->avctx->height = s->height; 2894 s->avctx->height = s->height;
2903 s->avctx->aspect_ratio= new_aspect; 2895 s->avctx->sample_aspect_ratio= h->sps.sar;
2904 } 2896 }
2905 2897
2906 if(first_mb_in_slice == 0){ 2898 if(first_mb_in_slice == 0){
2907 frame_start(h); 2899 frame_start(h);
2908 } 2900 }
3734 aspect_ratio_info_present_flag= get_bits1(&s->gb); 3726 aspect_ratio_info_present_flag= get_bits1(&s->gb);
3735 3727
3736 if( aspect_ratio_info_present_flag ) { 3728 if( aspect_ratio_info_present_flag ) {
3737 aspect_ratio_idc= get_bits(&s->gb, 8); 3729 aspect_ratio_idc= get_bits(&s->gb, 8);
3738 if( aspect_ratio_idc == EXTENDED_SAR ) { 3730 if( aspect_ratio_idc == EXTENDED_SAR ) {
3739 sps->sar_width= get_bits(&s->gb, 16); 3731 sps->sar.num= get_bits(&s->gb, 16);
3740 sps->sar_height= get_bits(&s->gb, 16); 3732 sps->sar.den= get_bits(&s->gb, 16);
3741 }else if(aspect_ratio_idc < 16){ 3733 }else if(aspect_ratio_idc < 16){
3742 sps->sar_width= pixel_aspect[aspect_ratio_idc][0]; 3734 sps->sar= pixel_aspect[aspect_ratio_idc];
3743 sps->sar_height= pixel_aspect[aspect_ratio_idc][1];
3744 }else{ 3735 }else{
3745 fprintf(stderr, "illegal aspect ratio\n"); 3736 fprintf(stderr, "illegal aspect ratio\n");
3746 return -1; 3737 return -1;
3747 } 3738 }
3748 }else{ 3739 }else{
3749 sps->sar_width= 3740 sps->sar.num=
3750 sps->sar_height= 0; 3741 sps->sar.den= 0;
3751 } 3742 }
3752 // s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height); 3743 // s->avctx->aspect_ratio= sar_width*s->width / (float)(s->height*sar_height);
3753 #if 0 3744 #if 0
3754 | overscan_info_present_flag |0 |u(1) | 3745 | overscan_info_present_flag |0 |u(1) |
3755 | if( overscan_info_present_flag ) | | | 3746 | if( overscan_info_present_flag ) | | |