comparison nutdec.c @ 2393:fc685315d568 libavformat

spelling/wording cosmetics
author diego
date Fri, 17 Aug 2007 10:45:50 +0000
parents a9dc7596498a
children 94908f6107ff
comparison
equal deleted inserted replaced
2392:39e9fb85fcbc 2393:fc685315d568
140 140
141 return 0; 141 return 0;
142 } 142 }
143 143
144 /** 144 /**
145 * find the given startcode. 145 * Find the given startcode.
146 * @param code the startcode 146 * @param code the startcode
147 * @param pos the start position of the search, or -1 if the current position 147 * @param pos the start position of the search, or -1 if the current position
148 * @returns the position of the startcode or -1 if not found 148 * @returns the position of the startcode or -1 if not found
149 */ 149 */
150 static int64_t find_startcode(ByteIOContext *bc, uint64_t code, int64_t pos){ 150 static int64_t find_startcode(ByteIOContext *bc, uint64_t code, int64_t pos){
263 } 263 }
264 } 264 }
265 assert(nut->frame_code['N'].flags == FLAG_INVALID); 265 assert(nut->frame_code['N'].flags == FLAG_INVALID);
266 266
267 if(skip_reserved(bc, end) || get_checksum(bc)){ 267 if(skip_reserved(bc, end) || get_checksum(bc)){
268 av_log(s, AV_LOG_ERROR, "Main header checksum mismatch\n"); 268 av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n");
269 return -1; 269 return -1;
270 } 270 }
271 271
272 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count); 272 nut->stream = av_mallocz(sizeof(StreamContext)*stream_count);
273 for(i=0; i<stream_count; i++){ 273 for(i=0; i<stream_count; i++){
317 // break; 317 // break;
318 case 3: 318 case 3:
319 st->codec->codec_type = CODEC_TYPE_DATA; 319 st->codec->codec_type = CODEC_TYPE_DATA;
320 break; 320 break;
321 default: 321 default:
322 av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class); 322 av_log(s, AV_LOG_ERROR, "unknown stream class (%d)\n", class);
323 return -1; 323 return -1;
324 } 324 }
325 GET_V(stc->time_base_id , tmp < nut->time_base_count); 325 GET_V(stc->time_base_id , tmp < nut->time_base_count);
326 GET_V(stc->msb_pts_shift , tmp < 16); 326 GET_V(stc->msb_pts_shift , tmp < 16);
327 stc->max_pts_distance= get_v(bc); 327 stc->max_pts_distance= get_v(bc);
328 GET_V(stc->decode_delay , tmp < 1000); //sanity limit, raise this if moors law is true 328 GET_V(stc->decode_delay , tmp < 1000); //sanity limit, raise this if Moore's law is true
329 st->codec->has_b_frames= stc->decode_delay; 329 st->codec->has_b_frames= stc->decode_delay;
330 get_v(bc); //stream flags 330 get_v(bc); //stream flags
331 331
332 GET_V(st->codec->extradata_size, tmp < (1<<30)); 332 GET_V(st->codec->extradata_size, tmp < (1<<30));
333 if(st->codec->extradata_size){ 333 if(st->codec->extradata_size){
347 get_v(bc); /* csp type */ 347 get_v(bc); /* csp type */
348 }else if (st->codec->codec_type == CODEC_TYPE_AUDIO){ 348 }else if (st->codec->codec_type == CODEC_TYPE_AUDIO){
349 GET_V(st->codec->sample_rate , tmp > 0) 349 GET_V(st->codec->sample_rate , tmp > 0)
350 tmp= get_v(bc); // samplerate_den 350 tmp= get_v(bc); // samplerate_den
351 if(tmp > st->codec->sample_rate){ 351 if(tmp > st->codec->sample_rate){
352 av_log(s, AV_LOG_ERROR, "bleh, libnut muxed this ;)\n"); 352 av_log(s, AV_LOG_ERROR, "Bleh, libnut muxed this ;)\n");
353 st->codec->sample_rate= tmp; 353 st->codec->sample_rate= tmp;
354 } 354 }
355 GET_V(st->codec->channels, tmp > 0) 355 GET_V(st->codec->channels, tmp > 0)
356 } 356 }
357 if(skip_reserved(bc, end) || get_checksum(bc)){ 357 if(skip_reserved(bc, end) || get_checksum(bc)){
358 av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id); 358 av_log(s, AV_LOG_ERROR, "stream header %d checksum mismatch\n", stream_id);
359 return -1; 359 return -1;
360 } 360 }
361 stc->time_base= &nut->time_base[stc->time_base_id]; 361 stc->time_base= &nut->time_base[stc->time_base_id];
362 av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den); 362 av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den);
363 return 0; 363 return 0;
413 av_strlcpy(s->comment , str_value, sizeof(s->comment)); 413 av_strlcpy(s->comment , str_value, sizeof(s->comment));
414 } 414 }
415 } 415 }
416 416
417 if(skip_reserved(bc, end) || get_checksum(bc)){ 417 if(skip_reserved(bc, end) || get_checksum(bc)){
418 av_log(s, AV_LOG_ERROR, "Info header checksum mismatch\n"); 418 av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
419 return -1; 419 return -1;
420 } 420 }
421 return 0; 421 return 0;
422 } 422 }
423 423
532 } 532 }
533 } 533 }
534 } 534 }
535 535
536 if(skip_reserved(bc, end) || get_checksum(bc)){ 536 if(skip_reserved(bc, end) || get_checksum(bc)){
537 av_log(s, AV_LOG_ERROR, "Index checksum mismatch\n"); 537 av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
538 return -1; 538 return -1;
539 } 539 }
540 return 0; 540 return 0;
541 } 541 }
542 542
552 /* main header */ 552 /* main header */
553 pos=0; 553 pos=0;
554 do{ 554 do{
555 pos= find_startcode(bc, MAIN_STARTCODE, pos)+1; 555 pos= find_startcode(bc, MAIN_STARTCODE, pos)+1;
556 if (pos<0+1){ 556 if (pos<0+1){
557 av_log(s, AV_LOG_ERROR, "no main startcode found\n"); 557 av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
558 return -1; 558 return -1;
559 } 559 }
560 }while(decode_main_header(nut) < 0); 560 }while(decode_main_header(nut) < 0);
561 561
562 /* stream headers */ 562 /* stream headers */
563 pos=0; 563 pos=0;
564 for(inited_stream_count=0; inited_stream_count < s->nb_streams;){ 564 for(inited_stream_count=0; inited_stream_count < s->nb_streams;){
565 pos= find_startcode(bc, STREAM_STARTCODE, pos)+1; 565 pos= find_startcode(bc, STREAM_STARTCODE, pos)+1;
566 if (pos<0+1){ 566 if (pos<0+1){
567 av_log(s, AV_LOG_ERROR, "not all stream headers found\n"); 567 av_log(s, AV_LOG_ERROR, "Not all stream headers found.\n");
568 return -1; 568 return -1;
569 } 569 }
570 if(decode_stream_header(nut) >= 0) 570 if(decode_stream_header(nut) >= 0)
571 inited_stream_count++; 571 inited_stream_count++;
572 } 572 }
608 StreamContext *stc; 608 StreamContext *stc;
609 int size, flags, size_mul, pts_delta, i, reserved_count; 609 int size, flags, size_mul, pts_delta, i, reserved_count;
610 uint64_t tmp; 610 uint64_t tmp;
611 611
612 if(url_ftell(bc) > nut->last_syncpoint_pos + nut->max_distance){ 612 if(url_ftell(bc) > nut->last_syncpoint_pos + nut->max_distance){
613 av_log(s, AV_LOG_ERROR, "last frame must have been damaged %"PRId64" > %"PRId64" + %d\n", url_ftell(bc), nut->last_syncpoint_pos, nut->max_distance); 613 av_log(s, AV_LOG_ERROR, "Last frame must have been damaged %"PRId64" > %"PRId64" + %d\n", url_ftell(bc), nut->last_syncpoint_pos, nut->max_distance);
614 return -1; 614 return -1;
615 } 615 }
616 616
617 flags = nut->frame_code[frame_code].flags; 617 flags = nut->frame_code[frame_code].flags;
618 size_mul = nut->frame_code[frame_code].size_mul; 618 size_mul = nut->frame_code[frame_code].size_mul;
760 resync: 760 resync:
761 do{ 761 do{
762 pos= find_startcode(bc, SYNCPOINT_STARTCODE, pos)+1; 762 pos= find_startcode(bc, SYNCPOINT_STARTCODE, pos)+1;
763 if(pos < 1){ 763 if(pos < 1){
764 assert(nut->next_startcode == 0); 764 assert(nut->next_startcode == 0);
765 av_log(s, AV_LOG_ERROR, "read_timestamp failed\n"); 765 av_log(s, AV_LOG_ERROR, "read_timestamp failed.\n");
766 return AV_NOPTS_VALUE; 766 return AV_NOPTS_VALUE;
767 } 767 }
768 }while(decode_syncpoint(nut, &pts, &back_ptr) < 0); 768 }while(decode_syncpoint(nut, &pts, &back_ptr) < 0);
769 *pos_arg = pos-1; 769 *pos_arg = pos-1;
770 assert(nut->last_syncpoint_pos == *pos_arg); 770 assert(nut->last_syncpoint_pos == *pos_arg);