fix vorbis in ogg decoding Originally committed as revision 2952 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -4,8 +4,6 @@ | |||||
| * @author Mark Hills <mark@pogo.org.uk> | * @author Mark Hills <mark@pogo.org.uk> | ||||
| */ | */ | ||||
| #include <time.h> | |||||
| #include <vorbis/vorbisenc.h> | #include <vorbis/vorbisenc.h> | ||||
| #include "avcodec.h" | #include "avcodec.h" | ||||
| @@ -185,22 +183,36 @@ static int oggvorbis_decode_frame(AVCodecContext *avccontext, | |||||
| OggVorbisContext *context = avccontext->priv_data ; | OggVorbisContext *context = avccontext->priv_data ; | ||||
| ogg_packet *op = (ogg_packet*)buf ; | ogg_packet *op = (ogg_packet*)buf ; | ||||
| float **pcm ; | float **pcm ; | ||||
| int samples, total_samples, total_bytes ; | |||||
| int samples, total_samples, total_bytes,i; | |||||
| if(!buf_size){ | |||||
| //FIXME flush | |||||
| *data_size=0; | |||||
| return 0; | |||||
| } | |||||
| op->packet = (char*)op + sizeof(ogg_packet) ; /* correct data pointer */ | op->packet = (char*)op + sizeof(ogg_packet) ; /* correct data pointer */ | ||||
| // av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %lld %lld %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate); | |||||
| /* for(i=0; i<op->bytes; i++) | |||||
| av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]); | |||||
| av_log(avccontext, AV_LOG_DEBUG, "\n");*/ | |||||
| // op->b_o_s= op->packetno == 0; | |||||
| if(op->packetno < 3) { | if(op->packetno < 3) { | ||||
| vorbis_synthesis_headerin(&context->vi, &context->vc, op) ; | |||||
| if(vorbis_synthesis_headerin(&context->vi, &context->vc, op)<0){ | |||||
| av_log(avccontext, AV_LOG_ERROR, "%lld. vorbis header damaged\n", op->packetno+1); | |||||
| return -1; | |||||
| } | |||||
| avccontext->channels = context->vi.channels ; | |||||
| avccontext->sample_rate = context->vi.rate ; | |||||
| return buf_size ; | return buf_size ; | ||||
| } | } | ||||
| if(op->packetno == 3) { | if(op->packetno == 3) { | ||||
| av_log(avccontext, AV_LOG_ERROR, "vorbis_decode: %d channel, %ldHz, encoder `%s'\n", | |||||
| context->vi.channels, context->vi.rate, context->vc.vendor); | |||||
| // av_log(avccontext, AV_LOG_INFO, "vorbis_decode: %d channel, %ldHz, encoder `%s'\n", | |||||
| // context->vi.channels, context->vi.rate, context->vc.vendor); | |||||
| avccontext->channels = context->vi.channels ; | |||||
| avccontext->sample_rate = context->vi.rate ; | |||||
| vorbis_synthesis_init(&context->vd, &context->vi) ; | vorbis_synthesis_init(&context->vd, &context->vi) ; | ||||
| vorbis_block_init(&context->vd, &context->vb); | vorbis_block_init(&context->vd, &context->vb); | ||||
| } | } | ||||
| @@ -7,7 +7,6 @@ | |||||
| */ | */ | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <time.h> | |||||
| #include <ogg/ogg.h> | #include <ogg/ogg.h> | ||||
| #include <vorbis/vorbisenc.h> | #include <vorbis/vorbisenc.h> | ||||
| @@ -42,8 +41,7 @@ static int ogg_write_header(AVFormatContext *avfcontext) | |||||
| ogg_packet header, header_comm, header_code ; | ogg_packet header, header_comm, header_code ; | ||||
| int n ; | int n ; | ||||
| srand(time(NULL)); | |||||
| ogg_stream_init(&context->os, rand()); | |||||
| ogg_stream_init(&context->os, 31415); | |||||
| for(n = 0 ; n < avfcontext->nb_streams ; n++) { | for(n = 0 ; n < avfcontext->nb_streams ; n++) { | ||||
| avccontext = &avfcontext->streams[n]->codec ; | avccontext = &avfcontext->streams[n]->codec ; | ||||
| @@ -196,7 +194,9 @@ static int ogg_read_header(AVFormatContext *avfcontext, AVFormatParameters *ap) | |||||
| char *buf ; | char *buf ; | ||||
| ogg_page og ; | ogg_page og ; | ||||
| AVStream *ast ; | AVStream *ast ; | ||||
| avfcontext->ctx_flags |= AVFMTCTX_NOHEADER; | |||||
| ogg_sync_init(&context->oy) ; | ogg_sync_init(&context->oy) ; | ||||
| buf = ogg_sync_buffer(&context->oy, DECODER_BUFFER_SIZE) ; | buf = ogg_sync_buffer(&context->oy, DECODER_BUFFER_SIZE) ; | ||||
| @@ -1476,6 +1476,7 @@ int av_find_stream_info(AVFormatContext *ic) | |||||
| (st->codec.codec_id == CODEC_ID_FLV1 || | (st->codec.codec_id == CODEC_ID_FLV1 || | ||||
| st->codec.codec_id == CODEC_ID_H264 || | st->codec.codec_id == CODEC_ID_H264 || | ||||
| st->codec.codec_id == CODEC_ID_H263 || | st->codec.codec_id == CODEC_ID_H263 || | ||||
| st->codec.codec_id == CODEC_ID_VORBIS || | |||||
| (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))) | (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))) | ||||
| try_decode_frame(st, pkt->data, pkt->size); | try_decode_frame(st, pkt->data, pkt->size); | ||||
| @@ -1864,7 +1865,7 @@ int parse_frame_rate(int *frame_rate, int *frame_rate_base, const char *arg) | |||||
| } | } | ||||
| else { | else { | ||||
| /* Finally we give up and parse it as double */ | /* Finally we give up and parse it as double */ | ||||
| *frame_rate_base = DEFAULT_FRAME_RATE_BASE; | |||||
| *frame_rate_base = DEFAULT_FRAME_RATE_BASE; //FIXME use av_d2q() | |||||
| *frame_rate = (int)(strtod(arg, 0) * (*frame_rate_base) + 0.5); | *frame_rate = (int)(strtod(arg, 0) * (*frame_rate_base) + 0.5); | ||||
| } | } | ||||
| if (!*frame_rate || !*frame_rate_base) | if (!*frame_rate || !*frame_rate_base) | ||||