Revision 5aa0a644 libavformat/nut.c
libavformat/nut.c  

63  63 
{ 
64  64 
uint64_t val = 0; 
65  65  
66 
// for (; bytes_left(s)*8 > 0; ) 

67  66 
for(; bytes_left(bc) > 0; ) 
68  67 
{ 
69  68 
int tmp = get_byte(bc); 
...  ...  
93  92 
len = get_v(bc); 
94  93 
for (i = 0; i < len && i < maxlen; i++) 
95  94 
data[i] = get_byte(bc); 
96 
if (i < len) 

97 
{ 

98 
len = i; 

99 
for (i = 0; i < len; i++) 

100 
get_byte(bc); 

101 
} 

95 
/* skip remaining bytes */ 

96 
for (; i < len; i++) 

97 
get_byte(bc); 

102  98  
103  99 
return 0; 
104  100 
} 
105  101  
106  102 
static int get_bi(ByteIOContext *bc) 
107  103 
{ 
108 
int i, len, val; 

104 
int i, len, val = 0;


109  105 

110  106 
len = get_v(bc); 
111 
if(len > 4) return 1; 

112 


113 
val = 0; 

114 
for (i = 0; i < len; i++) { 

107 
for (i = 0; i < len && i <= 4; i++) 

115  108 
val = get_byte(bc) << (i * 8); 
116 
} 

109 
/* skip remaining bytes */ 

110 
for (; i < len; i++) 

111 
get_byte(bc); 

117  112  
118  113 
return val; 
119  114 
} 
...  ...  
232  227 
ByteIOContext *bc = &s>pb; 
233  228 
AVCodecContext *codec; 
234  229 
int i; 
235 
int stream_length = 0; 

236  
237 
for (i = 0; i < s>nb_streams; i++) 

238 
{ 

239 
if (stream_length < (s>streams[i]>duration * (AV_TIME_BASE / 1000))) 

240 
stream_length = s>streams[i]>duration * (AV_TIME_BASE / 1000); 

241 
} 

242  230  
243  231 
/* main header */ 
244  232 
put_be64(bc, MAIN_STARTCODE); 
245  233 
put_packetheader(nut, bc, 120); 
246  234 
put_v(bc, 0); /* version */ 
247  235 
put_v(bc, s>nb_streams); 
248 
put_v(bc, 0); /* file size */ 

249 
put_v(bc, stream_length); /* len in msec */ 

250  236 
put_be32(bc, 0); /* FIXME: checksum */ 
251  237 

252  238 
update_packetheader(nut, bc, 0); 
...  ...  
439  425 
fprintf(stderr, "bad version (%Ld)\n", tmp); 
440  426 

441  427 
nb_streams = get_v(bc); 
442 


443 
s>file_size = get_v(bc); 

444 
s>duration = get_v(bc) / (AV_TIME_BASE / 1000); 

445  
446  428 
get_be32(bc); /* checkusm */ 
447  429 

448  430 
s>bit_rate = 0; 
Also available in: Unified diff