From: Ali Gholami Rudi Date: Fri, 27 Apr 2012 05:11:17 +0000 (+0430) Subject: ffs: revert to the old ffmpeg api in ffs_adec() X-Git-Url: https://repo.or.cz/w/fbff.git/commitdiff_plain/bcf8322de9d8b5d94f82db6fc6c6266fd5616fa7 ffs: revert to the old ffmpeg api in ffs_adec() The new function avcodec_decode_audio4() relies on the new AFPacket.nb_samples. So I cannot use frame->linesize[0] to get the size of the audio data. This means I should just redo most of the things done in the avcodec_decode_audio3() wrapper around avcodec_decode_audio4(); it is undeniably ugly. So I'll stick with avcodec_decode_audio3() for now. I hope one day the ffmpeg people learn how to design the API. Reported-by: Sara Fauzia --- diff --git a/ffs.c b/ffs.c index 3e1f576..96d0eaf 100644 --- a/ffs.c +++ b/ffs.c @@ -166,7 +166,6 @@ int ffs_vdec(struct ffs *ffs, void **buf) int ffs_adec(struct ffs *ffs, void *buf, int blen) { - int len, got; int rdec = 0; AVPacket tmppkt = {0}; AVPacket *pkt = ffs_pkt(ffs); @@ -175,15 +174,17 @@ int ffs_adec(struct ffs *ffs, void *buf, int blen) tmppkt.size = pkt->size; tmppkt.data = pkt->data; while (tmppkt.size > 0) { - len = avcodec_decode_audio4(ffs->cc, ffs->dst, &got, &tmppkt); + int size = blen - rdec; + int len = avcodec_decode_audio3(ffs->cc, (int16_t *) (buf + rdec), + &size, &tmppkt); if (len < 0) break; tmppkt.size -= len; tmppkt.data += len; + if (size > 0) + rdec += size; } av_free_packet(pkt); - rdec = ffs->dst->linesize[0]; - memcpy(buf, ffs->dst->data[0], rdec); return rdec; }