comparison mpeg12.c @ 2575:0afef2899701 libavcodec

more checks, fixes assertion failure
author michael
date Sat, 26 Mar 2005 17:01:49 +0000
parents d69789acdbc4
children 4aba13499a91
comparison
equal deleted inserted replaced
2574:9973475ccf1e 2575:0afef2899701
1078 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; 1078 s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
1079 s->field_select[0][0]= s->picture_structure - 1; 1079 s->field_select[0][0]= s->picture_structure - 1;
1080 s->mb_skiped = 1; 1080 s->mb_skiped = 1;
1081 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; 1081 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;
1082 } else { 1082 } else {
1083 int mb_type;
1084
1085 if(s->mb_x)
1086 mb_type= s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1];
1087 else
1088 mb_type= s->current_picture.mb_type[ s->mb_width + (s->mb_y-1)*s->mb_stride - 1]; // FIXME not sure if this is allowed in mpeg at all,
1089 if(IS_INTRA(mb_type))
1090 return -1;
1091
1083 /* if B type, reuse previous vectors and directions */ 1092 /* if B type, reuse previous vectors and directions */
1084 s->mv[0][0][0] = s->last_mv[0][0][0]; 1093 s->mv[0][0][0] = s->last_mv[0][0][0];
1085 s->mv[0][0][1] = s->last_mv[0][0][1]; 1094 s->mv[0][0][1] = s->last_mv[0][0][1];
1086 s->mv[1][0][0] = s->last_mv[1][0][0]; 1095 s->mv[1][0][0] = s->last_mv[1][0][0];
1087 s->mv[1][0][1] = s->last_mv[1][0][1]; 1096 s->mv[1][0][1] = s->last_mv[1][0][1];
1088 1097
1089 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]= 1098 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride ]=
1090 s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1] | MB_TYPE_SKIP; 1099 mb_type | MB_TYPE_SKIP;
1091 // assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8)); 1100 // assert(s->current_picture.mb_type[ s->mb_x + s->mb_y*s->mb_stride - 1]&(MB_TYPE_16x16|MB_TYPE_16x8));
1092 1101
1093 if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0) 1102 if((s->mv[0][0][0]|s->mv[0][0][1]|s->mv[1][0][0]|s->mv[1][0][1])==0)
1094 s->mb_skiped = 1; 1103 s->mb_skiped = 1;
1095 } 1104 }
2102 2111
2103 init_get_bits(&s->gb, buf, buf_size*8); 2112 init_get_bits(&s->gb, buf, buf_size*8);
2104 2113
2105 ref = get_bits(&s->gb, 10); /* temporal ref */ 2114 ref = get_bits(&s->gb, 10); /* temporal ref */
2106 s->pict_type = get_bits(&s->gb, 3); 2115 s->pict_type = get_bits(&s->gb, 3);
2116 if(s->pict_type == 0 || s->pict_type > 3)
2117 return -1;
2107 2118
2108 vbv_delay= get_bits(&s->gb, 16); 2119 vbv_delay= get_bits(&s->gb, 16);
2109 if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) { 2120 if (s->pict_type == P_TYPE || s->pict_type == B_TYPE) {
2110 s->full_pel[0] = get_bits1(&s->gb); 2121 s->full_pel[0] = get_bits1(&s->gb);
2111 f_code = get_bits(&s->gb, 3); 2122 f_code = get_bits(&s->gb, 3);
2123 s->mpeg_f_code[1][1] = f_code; 2134 s->mpeg_f_code[1][1] = f_code;
2124 } 2135 }
2125 s->current_picture.pict_type= s->pict_type; 2136 s->current_picture.pict_type= s->pict_type;
2126 s->current_picture.key_frame= s->pict_type == I_TYPE; 2137 s->current_picture.key_frame= s->pict_type == I_TYPE;
2127 2138
2128 // if(avctx->debug & FF_DEBUG_PICT_INFO) 2139 if(avctx->debug & FF_DEBUG_PICT_INFO)
2129 // av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d\n", vbv_delay, ref); 2140 av_log(avctx, AV_LOG_DEBUG, "vbv_delay %d, ref %d type:%d\n", vbv_delay, ref, s->pict_type);
2130 2141
2131 s->y_dc_scale = 8; 2142 s->y_dc_scale = 8;
2132 s->c_dc_scale = 8; 2143 s->c_dc_scale = 8;
2133 s->first_slice = 1; 2144 s->first_slice = 1;
2134 return 0; 2145 return 0;