diff options
author | Måns Rullgård <mans@mansr.com> | 2005-05-19 11:45:10 +0000 |
---|---|---|
committer | Måns Rullgård <mans@mansr.com> | 2005-05-19 11:45:10 +0000 |
commit | 2c578058313e1f62c9d7e939a0e350eab95af669 (patch) | |
tree | beaf7f012393909ff078f90c4481308cb08335af /libavcodec/oggvorbis.c | |
parent | d381c5054a7746ea4bfbde33d91f65302a8f285d (diff) | |
download | ffmpeg-2c578058313e1f62c9d7e939a0e350eab95af669.tar.gz |
accept old extradata format
Originally committed as revision 4281 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/oggvorbis.c')
-rw-r--r-- | libavcodec/oggvorbis.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/libavcodec/oggvorbis.c b/libavcodec/oggvorbis.c index 9a47aeec97..dc7a8c6ed3 100644 --- a/libavcodec/oggvorbis.c +++ b/libavcodec/oggvorbis.c @@ -180,13 +180,11 @@ AVCodec oggvorbis_encoder = { .capabilities= CODEC_CAP_DELAY, } ; - static int oggvorbis_decode_init(AVCodecContext *avccontext) { OggVorbisContext *context = avccontext->priv_data ; uint8_t *p= avccontext->extradata; int i, hsizes[3]; unsigned char *headers[3], *extradata = avccontext->extradata; - unsigned int offset; vorbis_info_init(&context->vi) ; vorbis_comment_init(&context->vc) ; @@ -195,37 +193,47 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) { av_log(avccontext, AV_LOG_ERROR, "vorbis extradata absent\n"); return -1; } - if(*p != 2) { - av_log(avccontext, AV_LOG_ERROR, - "vorbis initial header len is wrong: %d\n", *p); - return -1; - } - offset = 1; - p++; - for(i=0; i<2; i++) { - hsizes[i] = 0; - while((*p == 0xFF) && (offset < avccontext->extradata_size)) { - hsizes[i] += 0xFF; + + if(p[0] == 0 && p[1] == 30) { + for(i = 0; i < 3; i++){ + hsizes[i] = *p++ << 8; + hsizes[i] += *p++; + headers[i] = p; + p += hsizes[i]; + } + } else if(*p == 2) { + unsigned int offset = 1; + p++; + for(i=0; i<2; i++) { + hsizes[i] = 0; + while((*p == 0xFF) && (offset < avccontext->extradata_size)) { + hsizes[i] += 0xFF; + offset++; + p++; + } + if(offset >= avccontext->extradata_size - 1) { + av_log(avccontext, AV_LOG_ERROR, + "vorbis header sizes damaged\n"); + return -1; + } + hsizes[i] += *p; offset++; p++; } - if(offset >= avccontext->extradata_size - 1) { - av_log(avccontext, AV_LOG_ERROR, "vorbis header sizes damaged\n"); - return -1; - } - hsizes[i] += *p; - offset++; - p++; - } - hsizes[2] = avccontext->extradata_size - hsizes[0] - hsizes[1] - offset; + hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset; #if 0 - av_log(avccontext, AV_LOG_DEBUG, - "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n", - hsizes[0], hsizes[1], hsizes[2], avccontext->extradata_size); + av_log(avccontext, AV_LOG_DEBUG, + "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n", + hsizes[0], hsizes[1], hsizes[2], avccontext->extradata_size); #endif - headers[0] = extradata + offset; - headers[1] = extradata + offset + hsizes[0]; - headers[2] = extradata + offset + hsizes[0] + hsizes[1]; + headers[0] = extradata + offset; + headers[1] = extradata + offset + hsizes[0]; + headers[2] = extradata + offset + hsizes[0] + hsizes[1]; + } else { + av_log(avccontext, AV_LOG_ERROR, + "vorbis initial header len is wrong: %d\n", *p); + return -1; + } for(i=0; i<3; i++){ context->op.b_o_s= i==0; @@ -236,6 +244,7 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) { return -1; } } + avccontext->channels = context->vi.channels; avccontext->sample_rate = context->vi.rate; avccontext->time_base= (AVRational){1, avccontext->sample_rate}; |