Revision 37cdf93d

View differences:

libavformat/flvenc.c
34 34
    put_byte(pb, (value>> 0) & 0xFF );
35 35
}
36 36

  
37
static int get_audio_flags(AVCodecContext *enc){
38
    int flags = 0x02;
39

  
40
    switch (enc->sample_rate) {
41
        case    44100:
42
            flags |= 0x0C;
43
            break;
44
        case    22050:
45
            flags |= 0x08;
46
            break;
47
        case    11025:
48
            flags |= 0x04;
49
            break;
50
        case     8000: //nellymoser only
51
        case     5512: //not mp3
52
            flags |= 0x00;
53
            break;
54
        default:
55
            return -1;
56
    }
57

  
58
    if (enc->channels > 1) {
59
        flags |= 0x01;
60
    }
61
    
62
    switch(enc->codec_id){
63
    case CODEC_ID_MP3:
64
        flags |= 0x20;
65
        break;
66
    case 0:
67
        flags |= enc->codec_tag<<4;
68
        break;
69
    default:
70
        return -1;
71
    }
72
    
73
    return flags;
74
}
75

  
37 76
static int flv_write_header(AVFormatContext *s)
38 77
{
39 78
    ByteIOContext *pb = &s->pb;
......
60 99
            put_be32(pb,11); // size
61 100
            flv->reserved=5;
62 101
        }
102
        if(enc->codec_type == CODEC_TYPE_AUDIO && get_audio_flags(enc)<0)
103
            return -1;
63 104
    }
64 105

  
65 106
    return 0;
......
99 140
        flv->hasVideo = 1;
100 141
    } else {
101 142
        assert(enc->codec_type == CODEC_TYPE_AUDIO);
102
        flags = 0x02;
103

  
104
        switch (enc->sample_rate) {
105
            case    44100:
106
                flags |= 0x0C;
107
                break;
108
            case    22050:
109
                flags |= 0x08;
110
                break;
111
            case    11025:
112
                flags |= 0x04;
113
                break;
114
            case     8000: //nellymoser only
115
            case     5512: //not mp3
116
                flags |= 0x00;
117
                break;
118
            default:
119
                assert(0);
120
        }
121

  
122
        if (enc->channels > 1) {
123
            flags |= 0x01;
124
        }
143
        flags = get_audio_flags(enc);
125 144
        
126
        switch(enc->codec_id){
127
        case CODEC_ID_MP3:
128
            flags |= 0x20;
129
            break;
130
        case 0:
131
            flags |= enc->codec_tag<<4;
132
            break;
133
        default:
134
            assert(0);
135
        }
136

  
137 145
        assert(size);
138 146

  
139 147
        put_byte(pb, 8);

Also available in: Unified diff