avcodec: Use av_reallocp where suitable