Revision 01bd1ed2

View differences:

libavformat/nut.c
112 112
	{"Cover"		, "PNG"},
113 113
};
114 114

  
115
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);
116

  
115 117
static void update(NUTContext *nut, int stream_index, int64_t frame_start, int frame_type, int frame_code, int key_frame, int size, int64_t pts){
116 118
    StreamContext *stream= &nut->stream[stream_index];
117 119
    
......
576 578
    /* stream headers */
577 579
    for (i = 0; i < s->nb_streams; i++)
578 580
    {
579
	int nom, denom, gcd;
581
	int nom, denom, ssize;
580 582

  
581 583
	codec = &s->streams[i]->codec;
582 584
	
583 585
	put_be64(bc, STREAM_STARTCODE);
584 586
	put_packetheader(nut, bc, 120 + codec->extradata_size, 1);
585 587
	put_v(bc, i /*s->streams[i]->index*/);
586
	put_v(bc, (codec->codec_type == CODEC_TYPE_AUDIO) ? 32 : 0);
588
        switch(codec->codec_type){
589
        case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
590
        case CODEC_TYPE_AUDIO: put_v(bc, 1); break;
591
//        case CODEC_TYPE_TEXT : put_v(bc, 2); break;
592
        case CODEC_TYPE_DATA : put_v(bc, 3); break;
593
        default: return -1;
594
        }
587 595
	if (codec->codec_tag)
588 596
	    put_vb(bc, codec->codec_tag);
589 597
	else if (codec->codec_type == CODEC_TYPE_VIDEO)
......
596 604
	}
597 605
        else
598 606
            put_vb(bc, 0);
607
        
608
        ff_parse_specific_params(codec, &nom, &ssize, &denom);
599 609

  
600
	if (codec->codec_type == CODEC_TYPE_VIDEO)
601
	{
602
	    nom = codec->time_base.den;
603
	    denom = codec->time_base.num;
604
	}
605
	else
606
	{
607
	    nom = codec->sample_rate;
608
            if(codec->frame_size>0)
609
                denom= codec->frame_size;
610
            else
611
                denom= 1; //unlucky
612
	}
613
        gcd= ff_gcd(nom, denom);
614
        nom   /= gcd;
615
        denom /= gcd;
616 610
        nut->stream[i].rate_num= nom;
617 611
        nut->stream[i].rate_den= denom;
618 612
        av_set_pts_info(s->streams[i], 60, denom, nom);
......
965 959
            if (st->codec.codec_id == CODEC_ID_NONE)
966 960
                av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
967 961
            break;
968
        case 32:
962
        case 1:
963
        case 32: //compatibility
969 964
            st->codec.codec_type = CODEC_TYPE_AUDIO;
970 965
            st->codec.codec_id = codec_get_wav_id(tmp);
971 966
            if (st->codec.codec_id == CODEC_ID_NONE)
972 967
                av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
973 968
            break;
969
        case 2:
970
//            st->codec.codec_type = CODEC_TYPE_TEXT;
971
//            break;
972
        case 3:
973
            st->codec.codec_type = CODEC_TYPE_DATA;
974
            break;
974 975
        default:
975 976
            av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
976 977
            return -1;
......
994 995
//	    url_fskip(bc, get_v(bc));
995 996
    }
996 997
    
997
    if (class == 0) /* VIDEO */
998
    if (st->codec.codec_type == CODEC_TYPE_VIDEO) /* VIDEO */
998 999
    {
999 1000
        st->codec.width = get_v(bc);
1000 1001
        st->codec.height = get_v(bc);
......
1002 1003
        st->codec.sample_aspect_ratio.den= get_v(bc);
1003 1004
        get_v(bc); /* csp type */
1004 1005
    }
1005
    if (class == 32) /* AUDIO */
1006
    if (st->codec.codec_type == CODEC_TYPE_AUDIO) /* AUDIO */
1006 1007
    {
1007 1008
        st->codec.sample_rate = get_v(bc);
1008 1009
        get_v(bc); // samplerate_den
......
1100 1101
    pos=0;
1101 1102
    for(inited_stream_count=0; inited_stream_count < nut->stream_count;){
1102 1103
        pos= find_startcode(bc, STREAM_STARTCODE, pos)+1;
1103
        if (pos<0){
1104
        if (pos<0+1){
1104 1105
            av_log(s, AV_LOG_ERROR, "not all stream headers found\n");
1105 1106
            return -1;
1106 1107
        }

Also available in: Unified diff