comparison h264.c @ 7462:5cbf11f56c02 libavcodec

Picture.ref_count/ref_poc have to be stored per field (actually also per slice but thats a seperate bug) Fixes at least: CABREF3_Sand_D.264 camp_mot_fld0_full.26l CVFI2_Sony_H.jsv CVNLFI2_Sony_H.jsv
author michael
date Sat, 02 Aug 2008 23:13:27 +0000
parents 30d38a880fde
children 38e9f32f8d43
comparison
equal deleted inserted replaced
7461:5bcf597a321c 7462:5cbf11f56c02
871 871
872 return; 872 return;
873 } 873 }
874 874
875 static inline void direct_dist_scale_factor(H264Context * const h){ 875 static inline void direct_dist_scale_factor(H264Context * const h){
876 const int poc = h->s.current_picture_ptr->poc; 876 MpegEncContext * const s = &h->s;
877 const int poc = h->s.current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
877 const int poc1 = h->ref_list[1][0].poc; 878 const int poc1 = h->ref_list[1][0].poc;
878 int i; 879 int i;
879 for(i=0; i<h->ref_count[0]; i++){ 880 for(i=0; i<h->ref_count[0]; i++){
880 int poc0 = h->ref_list[0][i].poc; 881 int poc0 = h->ref_list[0][i].poc;
881 int td = av_clip(poc1 - poc0, -128, 127); 882 int td = av_clip(poc1 - poc0, -128, 127);
897 static inline void direct_ref_list_init(H264Context * const h){ 898 static inline void direct_ref_list_init(H264Context * const h){
898 MpegEncContext * const s = &h->s; 899 MpegEncContext * const s = &h->s;
899 Picture * const ref1 = &h->ref_list[1][0]; 900 Picture * const ref1 = &h->ref_list[1][0];
900 Picture * const cur = s->current_picture_ptr; 901 Picture * const cur = s->current_picture_ptr;
901 int list, i, j; 902 int list, i, j;
903 int sidx= s->picture_structure&1;
902 if(cur->pict_type == FF_I_TYPE) 904 if(cur->pict_type == FF_I_TYPE)
903 cur->ref_count[0] = 0; 905 cur->ref_count[sidx][0] = 0;
904 if(cur->pict_type != FF_B_TYPE) 906 if(cur->pict_type != FF_B_TYPE)
905 cur->ref_count[1] = 0; 907 cur->ref_count[sidx][1] = 0;
906 for(list=0; list<2; list++){ 908 for(list=0; list<2; list++){
907 cur->ref_count[list] = h->ref_count[list]; 909 cur->ref_count[sidx][list] = h->ref_count[list];
908 for(j=0; j<h->ref_count[list]; j++) 910 for(j=0; j<h->ref_count[list]; j++)
909 cur->ref_poc[list][j] = h->ref_list[list][j].poc; 911 cur->ref_poc[sidx][list][j] = h->ref_list[list][j].poc;
910 } 912 }
911 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred) 913 if(cur->pict_type != FF_B_TYPE || h->direct_spatial_mv_pred)
912 return; 914 return;
913 for(list=0; list<2; list++){ 915 for(list=0; list<2; list++){
914 for(i=0; i<ref1->ref_count[list]; i++){ 916 for(i=0; i<ref1->ref_count[sidx][list]; i++){
915 const int poc = ref1->ref_poc[list][i]; 917 const int poc = ref1->ref_poc[sidx][list][i];
916 h->map_col_to_list0[list][i] = 0; /* bogus; fills in for missing frames */ 918 h->map_col_to_list0[list][i] = 0; /* bogus; fills in for missing frames */
917 for(j=0; j<h->ref_count[list]; j++) 919 for(j=0; j<h->ref_count[list]; j++)
918 if(h->ref_list[list][j].poc == poc){ 920 if(h->ref_list[list][j].poc == poc){
919 h->map_col_to_list0[list][i] = j; 921 h->map_col_to_list0[list][i] = j;
920 break; 922 break;
921 } 923 }
922 } 924 }
923 } 925 }
924 if(FRAME_MBAFF){ 926 if(FRAME_MBAFF){
925 for(list=0; list<2; list++){ 927 for(list=0; list<2; list++){
926 for(i=0; i<ref1->ref_count[list]; i++){ 928 for(i=0; i<ref1->ref_count[sidx][list]; i++){
927 j = h->map_col_to_list0[list][i]; 929 j = h->map_col_to_list0[list][i];
928 h->map_col_to_list0_field[list][2*i] = 2*j; 930 h->map_col_to_list0_field[list][2*i] = 2*j;
929 h->map_col_to_list0_field[list][2*i+1] = 2*j+1; 931 h->map_col_to_list0_field[list][2*i+1] = 2*j+1;
930 } 932 }
931 } 933 }
2721 if (parity == PICT_BOTTOM_FIELD) 2723 if (parity == PICT_BOTTOM_FIELD)
2722 pic->data[i] += pic->linesize[i]; 2724 pic->data[i] += pic->linesize[i];
2723 pic->reference = parity; 2725 pic->reference = parity;
2724 pic->linesize[i] *= 2; 2726 pic->linesize[i] *= 2;
2725 } 2727 }
2728 pic->poc= pic->field_poc[parity == PICT_BOTTOM_FIELD];
2726 } 2729 }
2727 2730
2728 static int split_field_copy(Picture *dest, Picture *src, 2731 static int split_field_copy(Picture *dest, Picture *src,
2729 int parity, int id_add){ 2732 int parity, int id_add){
2730 int match = !!(src->reference & parity); 2733 int match = !!(src->reference & parity);