Revision a03cbe5f libavformat/ogg.c

View differences:

libavformat/ogg.c
167 167
static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap)
168 168
{
169 169
    OggContext *context = avfcontext->priv_data;
170
    ogg_packet op ;    
170 171
    char *buf ;
171 172
    ogg_page og ;
172 173
    AVStream *ast ;
174
    AVCodecContext *codec;
175
    uint8_t *p;
176
    int i;
173 177
     
174 178
    avfcontext->ctx_flags |= AVFMTCTX_NOHEADER;
175 179
     
......
183 187
    ogg_sync_pageout(&context->oy, &og) ;
184 188
    ogg_stream_init(&context->os, ogg_page_serialno(&og)) ;
185 189
    ogg_stream_pagein(&context->os, &og) ;
186
  
190
    
187 191
    /* currently only one vorbis stream supported */
188 192

  
189 193
    ast = av_new_stream(avfcontext, 0) ;
190 194
    if(!ast)
191 195
	return AVERROR_NOMEM ;
192 196

  
193
    ast->codec.codec_type = CODEC_TYPE_AUDIO ;
194
    ast->codec.codec_id = CODEC_ID_VORBIS ;
195
    
197
    codec= &ast->codec;
198
    codec->codec_type = CODEC_TYPE_AUDIO;
199
    codec->codec_id = CODEC_ID_VORBIS;
200
    for(i=0; i<3; i++){
201
        if(next_packet(avfcontext, &op)){
202
            return -1;
203
        }
204
        codec->extradata_size+= 2 + op.bytes;
205
        codec->extradata= av_realloc(codec->extradata, codec->extradata_size);
206
        p= codec->extradata + codec->extradata_size - 2 - op.bytes;
207
        *(p++)= op.bytes>>8;
208
        *(p++)= op.bytes&0xFF;
209
        memcpy(p, op.packet, op.bytes);
210
    }
211

  
196 212
    return 0 ;
197 213
}
198 214

  
......
216 232

  
217 233
    ogg_stream_clear(&context->os) ;
218 234
    ogg_sync_clear(&context->oy) ;
235
    av_freep(&avfcontext->streams[0]->codec.extradata);
219 236

  
220 237
    return 0 ;
221 238
}

Also available in: Unified diff