Revision 79b0b66b

View differences:

libavcodec/faad.c
49 49
typedef struct {
50 50
    void* handle;               /* dlopen handle */
51 51
    void* faac_handle;          /* FAAD library handle */
52
    int frame_size;
53 52
    int sample_size;
54
    int flags;
53
    int init;
55 54

  
56 55
    /* faad calls */
57 56
    faacDecHandle FAADAPI (*faacDecOpen)(void);
......
111 110
#endif
112 111
    int r = 0;
113 112

  
114
    if (avctx->extradata)
113
    if (avctx->extradata){
115 114
        r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx->extradata,
116 115
                            avctx->extradata_size,
117 116
                            &samplerate, &channels);
118
    // else r = s->faacDecInit(s->faac_handle ... );
119

  
120
    if (r < 0)
121
        av_log(avctx, AV_LOG_ERROR, "faacDecInit2 failed r:%d   sr:%ld  ch:%ld  s:%d\n",
122
                r, samplerate, (long)channels, avctx->extradata_size);
123
    avctx->sample_rate = samplerate;
124
    avctx->channels = channels;
117
        if (r < 0){
118
            av_log(avctx, AV_LOG_ERROR,
119
                   "faacDecInit2 failed r:%d   sr:%ld  ch:%ld  s:%d\n",
120
                   r, samplerate, (long)channels, avctx->extradata_size);
121
        } else {
122
            avctx->sample_rate = samplerate;
123
            avctx->channels = channels;
124
            s->init = 1;
125
        }
126
    }
125 127

  
126 128
    return r;
127 129
}
......
155 157
        ? buf_size : (int)bytesconsumed;
156 158
#else
157 159

  
160
    if(!s->init){
161
        unsigned long srate;
162
        unsigned char channels;
163
        int r = faacDecInit(s->faac_handle, buf, buf_size, &srate, &channels);
164
        if(r < 0){
165
            av_log(avctx, AV_LOG_ERROR, "faac: codec init failed: %s\n",
166
                   s->faacDecGetErrorMessage(frame_info.error));
167
            return 0;
168
        }
169
        avctx->sample_rate = srate;
170
        avctx->channels = channels;
171
        s->init = 1;
172
    }
173

  
158 174
    out = s->faacDecDecode(s->faac_handle, &frame_info, (unsigned char*)buf, (unsigned long)buf_size);
159 175

  
160 176
    if (frame_info.error > 0) {

Also available in: Unified diff