comparison nutdec.c @ 3120:ea5623a8efde libavformat

Add 'disposition' bitfield to AVStream and use it for both muxing and demuxing of matroska and nut.
author eugeni
date Fri, 07 Mar 2008 19:25:09 +0000
parents 88e032ac11e7
children 4e6f5edefa76
comparison
equal deleted inserted replaced
3119:b1caac2f77ad 3120:ea5623a8efde
367 return -1; 367 return -1;
368 } 368 }
369 stc->time_base= &nut->time_base[stc->time_base_id]; 369 stc->time_base= &nut->time_base[stc->time_base_id];
370 av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den); 370 av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den);
371 return 0; 371 return 0;
372 }
373
374 static void set_disposition_bits(AVFormatContext* avf, char* value, int stream_id){
375 int flag = 0, i;
376 for (i=0; ff_nut_dispositions[i].flag; ++i) {
377 if (!strcmp(ff_nut_dispositions[i].str, value))
378 flag = ff_nut_dispositions[i].flag;
379 }
380 if (!flag)
381 av_log(avf, AV_LOG_INFO, "unknown disposition type '%s'\n", value);
382 for (i = 0; i < avf->nb_streams; ++i)
383 if (stream_id == i || stream_id == -1)
384 avf->streams[i]->disposition |= flag;
372 } 385 }
373 386
374 static int decode_info_header(NUTContext *nut){ 387 static int decode_info_header(NUTContext *nut){
375 AVFormatContext *s= nut->avf; 388 AVFormatContext *s= nut->avf;
376 ByteIOContext *bc = s->pb; 389 ByteIOContext *bc = s->pb;
410 get_s(bc); 423 get_s(bc);
411 }else{ 424 }else{
412 type= "v"; 425 type= "v";
413 } 426 }
414 427
428 if (stream_id_plus1 < 0 || stream_id_plus1 > s->nb_streams) {
429 av_log(s, AV_LOG_ERROR, "invalid stream id for info packet\n");
430 continue;
431 }
432
415 if(chapter_id==0 && !strcmp(type, "UTF-8")){ 433 if(chapter_id==0 && !strcmp(type, "UTF-8")){
416 if (!strcmp(name, "Author")) 434 if (!strcmp(name, "Author"))
417 av_strlcpy(s->author , str_value, sizeof(s->author)); 435 av_strlcpy(s->author , str_value, sizeof(s->author));
418 else if(!strcmp(name, "Title")) 436 else if(!strcmp(name, "Title"))
419 av_strlcpy(s->title , str_value, sizeof(s->title)); 437 av_strlcpy(s->title , str_value, sizeof(s->title));
420 else if(!strcmp(name, "Copyright")) 438 else if(!strcmp(name, "Copyright"))
421 av_strlcpy(s->copyright, str_value, sizeof(s->copyright)); 439 av_strlcpy(s->copyright, str_value, sizeof(s->copyright));
422 else if(!strcmp(name, "Description")) 440 else if(!strcmp(name, "Description"))
423 av_strlcpy(s->comment , str_value, sizeof(s->comment)); 441 av_strlcpy(s->comment , str_value, sizeof(s->comment));
442 else if(!strcmp(name, "Disposition"))
443 set_disposition_bits(s, str_value, stream_id_plus1 - 1);
424 } 444 }
425 } 445 }
426 446
427 if(skip_reserved(bc, end) || get_checksum(bc)){ 447 if(skip_reserved(bc, end) || get_checksum(bc)){
428 av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n"); 448 av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");