$NetBSD: patch-ad,v 1.2 2009/11/28 19:31:29 kefren Exp $ --- src/plugins/ffmpeg/ffmpeg.cpp.orig 2009-07-18 16:08:59.000000000 +0300 +++ src/plugins/ffmpeg/ffmpeg.cpp 2009-11-28 21:00:33.000000000 +0200 @@ -201,7 +201,7 @@ if(pFFmpeg->audio_sync_method){ double delta = get_sync_ipts(ost, pFFmpeg) * enc->sample_rate - ost->sync_opts - - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2); + - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2); double idelta= delta*ist->st->codec->sample_rate / enc->sample_rate; int byte_delta= ((int)idelta)*2*ist->st->codec->channels; @@ -238,13 +238,13 @@ assert(ost->audio_resample); if(pFFmpeg->verbose > 2) fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate); -// fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2)); +// fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2)); av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate); } } }else ost->sync_opts= lrintf(get_sync_ipts(ost, pFFmpeg) * enc->sample_rate) - - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2); //FIXME wrong + - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2); //FIXME wrong if (ost->audio_resample) { buftmp = audio_buf; @@ -260,11 +260,11 @@ /* now encode as many frames as possible */ if (enc->frame_size > 1) { /* output resampled raw samples */ - av_fifo_write(&ost->fifo, buftmp, size_out); + av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL); frame_bytes = enc->frame_size * 2 * enc->channels; - while (av_fifo_read(&ost->fifo, audio_buf, frame_bytes) == 0) { + while (av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL) == 0) { AVPacket pkt; av_init_packet(&pkt); @@ -1065,13 +1065,13 @@ switch(ost->st->codec->codec_type) { case CODEC_TYPE_AUDIO: - fifo_bytes = av_fifo_size(&ost->fifo); + fifo_bytes = av_fifo_size(ost->fifo); ret = 0; /* encode any samples remaining in fifo */ if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) { int fs_tmp = enc->frame_size; enc->frame_size = fifo_bytes / (2 * enc->channels); - if(av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes) == 0) { + if(av_fifo_generic_read(ost->fifo, (uint8_t *)samples, fifo_bytes, NULL) == 0) { ret = avcodec_encode_audio(enc, pFFmpeg->bit_buffer, pFFmpeg->bit_buffer_size, samples); } enc->frame_size = fs_tmp; @@ -1320,7 +1320,7 @@ } else { switch(codec->codec_type) { case CODEC_TYPE_AUDIO: - if (av_fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE)) + if ((ost->fifo = av_fifo_alloc(2 * MAX_AUDIO_PACKET_SIZE)) == NULL) goto fail; if (codec->channels == icodec->channels && @@ -1777,7 +1777,7 @@ fclose(ost->logfile); ost->logfile = NULL; } - av_fifo_free(&ost->fifo); /* works even if fifo is not + av_fifo_free(ost->fifo); /* works even if fifo is not initialized but set to zero */ av_free(ost->pict_tmp.data[0]); #ifdef HAVE_LIBSWSCALE